Cannot connect to my websocket using Cloudflare

So by now I had my website using websocket (PHP Ratchet) without cloudflare service at all. The websockets was over SSL (WWS) and worked as expected to. Once I added cloudflare on my website, I got errors.

I attach the code for my websocket server set up:
I attach the code for my websocket client set up:

When I run the server on my host terminal, it runs fine and does not echo any errors.

But when I enter my website (, I got error: dealspaceWebsocket.js:2 WebSocket connection to ‘wss://’ failed: Error during WebSocket handshake: Unexpected response code: 525

And please note, that I got different errors for different ports. When I set up the websocket to port 8443 I got the error above,
However when I change it to 8080 (Both on server and client side) It logs the following error (ONLY IN CLIENT SIDE, again - server side still runs correctly): WebSocket connection to ‘wss://’ failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR

I use FLEXIBLE type. I try to connect on client side to “wss://” (8443 is supported port of cloudflare for SSL connection). The connection between cloudflare to my server is over HTTP (FLEXIBLE type). The port my websocket on server listening to is 8443 also.
When I try to use the websocket (for example in js: new Websocket(‘wss://’)) , it stucks on CONNECTIONG state for a while, then terminates because of TIMOUT ERROR. any help?

This topic was automatically closed after 30 days. New replies are no longer allowed.