I'm trying to connect to a non-secure web socket server through WS, although when setting up a proxy with nginx I receive (on the WS server):
The handshake failed due to an unexpected packet format.
This is handled as an IOException
, and crashes the entire server.
stacktrace
Here is my nginx configuration:
server {
listen 80;
listen [::]:80;
server_name ws.tunnel.cf;
return 302 https://$server_name$request_uri;
}
server {
# SSL configuration
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/certs/cert.pem;
ssl_certificate_key /etc/ssl/private/key.pem;
server_name ws.tunnel.cf;
location / {
proxy_pass http://213.43.156.21:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
How exactly can I connect to my non secure web socket server, without making it WSS
?
I am using Fleck as a package for the server.
Code for connecting:
const socket = new WebSocket('wss://ws.tunnel.cf');
socket.addEventListener('open', function (event) {
console.log('WS:open');
});