My goal is to get push notifications from the web site (it provides socketIO interface). In order to do that I use socket.io-client library. I took the code from some socket.io examples. Here it is:
var io = require('socket.io-client');
socket = io.connect('https://cryptonit.net', {
port: 8080
});
socket.on('connect', function() {
console.log('connected');
});
socket.on('message', function(msg){
console.log(msg);
});
socket.on('disconnect', function() {
console.log('disconnected');
});
socket.on('error', function (e) {
console.log('System', e ? e : 'A unknown error occurred');
});
But I don't get any messages, neither I see that connection was established. What can be the possible source of the problem? How can I test this code?
Actually all examples I've seen were supposed to connect to the localhost, not to the real website.
I needed to change
socket = io.connect('https://cryptonit.net', {
port: 8080
});
to
socket = io.connect('https://cryptonit.net:8080');
to get it working.
Have no idea why the first one is wrong.