Webscoket + SSL + Cloudflare Protection


#1

Hello i google it but i find nothink …

12:32:09 system: Connecting to wss://domain.com:9095/
No protocol negotiation.
12:32:52 error: WebSocket error.
12:32:52 system: Connection closed.
Close status: 1006 (Abnormal Closure)

i Get this message wen i enable protection Cloudflare
Websocket works with protection?


#2

Cloudflare only proxies specific ports and I don’t believe 9095 is one of them. Here’s a list of allowed ports:


#3

Hi @cscharff,

I am using Cloudflare Flexible SSL but temporarily disabling the Always Use HTTPS setting for testing purposes.

I am trying to implement websocket via port 8080 using Socket.io on my app but I cannot make it to work over HTTPS. It is fine when I am viewing the app over HTTP whereby the clients are able to connect to the socket server.

FYI, the client app resides in a subdomain such as http://sub.domain.com while the NodeJS socket server resides at http://domain.com:8080.

On HTTPS mode however, the console output ERR_SSL_PROTOCOL_ERROR when the clients are trying to connect to the socket server. I read somewhere on the Cloudflare forum a guy suggested to set a Page Rule to disable SSL on the URL you are using to call the socket server such as (asterisk)domain.com:8080/(asterisk). I have tried this and it still doesn’t work.

It is vital for the web app to work in HTTPS.

Can you advise how to set this up properly?

Thank you.


#4

Port 8080 is a HTTP only port, won’t work with HTTPS. You need to use one of the HTTPS port listed on the article posted above.


#5

Hi @matteo,

I tried with port 8443 but I got a different error now.

Access to XMLHttpRequest at ‘https://domain.com:8443/socket.io/?EIO=3&transport=polling&t=MUWAhNu’ from origin ‘https://domain.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Tried doing this at the NodeJS server but no dice.

const server = require('http').createServer(function(request, response) {
    response.setHeader('Access-Control-Allow-Origin', '*');
});