Reputation: 7055
I have a problem with a weird socketio behavior, I don't want to post the whole context and problem. When I write: Server side :
this.io.on('connection....
Client side: intance = io();
I have not connection problem everything is working. When I write server side:
this.io.of('/data).on('connection....
client side:
instance = io('/data);
Everything goes work the client is popping "CONNECTION REFUSED". So I really don't understand. If anyone have an idea, out of context, of what it could be...
Upvotes: 2
Views: 1196
Reputation: 1574
Found a hint in the issues of the socket.io GitHub repos:
[..] I think this problem should happen only when using a relative path without a host. [..]
https://github.com/socketio/socket.io-client/issues/812#issuecomment-74377946
I could confirm this issue with Socket.io 1.3.7.
This is how you connect to a namespace when serving from a port other than port 80
:
server.js
import http from 'http';
import socketio from 'socket.io';
var server = http.createServer();
var io = socketio(server);
var nsp = io.of('/namespace');
client.js
import io from 'socket.io-client';
var nsp = io('http://localhost:4000/namespace');
Upvotes: 1