A
A
Alexey Ivanov2015-03-01 20:05:54
Node.js
Alexey Ivanov, 2015-03-01 20:05:54

How to make socket.io work over https?

Hello, how to make socket.io work over https protocol?
There is a separate machine where nodeJS is installed.
I bought an SSL certificate, but there was a problem with WS, because the call went over the http protocol.

var socket = io.connect('http://24.190.11.201:8047', {'reconnection': true});

What do I need to complete my task?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nazar Mokrinsky, 2015-03-02
@nazarpc

If you have WebSockets, then why do you write http?
For port 80, write ws://... for 443 with wss:// encryption, for the other you specify explicitly.
Something like wss://24.190.11.201:8047
For some reason http is written in the dock, so try https once you have a certificate.
The only question is how your server is configured, and whether it is generally correct.
If you need encryption - I would advise you to install Nginx, it will work with certificates and other things from its area of ​​​​responsibility, and your application will work with its own part.
In the Nginx config add something like this:

location ~ ^/WebSockets$ {
    proxy_pass			http://127.0.0.1:8080;
    proxy_http_version	1.1;
    proxy_set_header	Upgrade $http_upgrade;
    proxy_set_header	Connection	"upgrade";
  }

S
sasha, 2015-03-04
@madmages

stackoverflow.com/questions/9745249/html5-websocket...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question