New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node js - Socket.io-client is not connecting to socket.io server #828
Comments
// Connect to server Use like This // Connect to server |
I have the same issue.After adding the below lines also issue connection issue not solved. var io = require('socket.io-client') |
Same issue. Doest work for me also... |
I have same issue, didn't worked |
I changed from localhost to 127.0.0.1 and it worked. |
It did not work for me . |
For future readers, you need to explicitly specify the protocol (as the Node.js process has no // does not work
io.connect("localhost:8080");
// does work
io.connect("http://localhost:8080"); That being said, I think the client should throw an error instead of silently failing. |
Thanks for this suggestion, it worked for me |
It worked for me
|
none worked for me same error this is my conection const server = require('http').createServer(app); |
I am trying to connect to a socket.io-client using the following code:
Server:
// Load requirements
var http = require('http'),
io = require('socket.io');
// Create server & socket
var server = http.createServer(function(req, res){
});
server.listen(8080);
io = io.listen(server);
// Add a connect listener
io.sockets.on('connection', function(socket) {
});
Client:
console.log('1');
// Connect to server
var io = require('socket.io-client')
var socket = io.connect('localhost:8080', {reconnect: true});
console.log('2');
// Add a connect listener
socket.on('connect', function(socket) {
console.log('Connected!');
});
console.log('3');
I don't get the Connected console log or Client Connected console log and I don't know why! The code sample is taken from another question posted: Link and I don't see any solution to the problem...
http://stackoverflow.com/questions/29108594/node-js-socket-io-client-is-not-connecting-to-socket-io-server
The text was updated successfully, but these errors were encountered: