Socket not responding to emit message #601

Closed
codecowboy opened this Issue Jan 6, 2014 · 1 comment

Comments

Projects
None yet
3 participants

I see a connected message but no response to the message I am emitting?

var io = require('socket.io-client'),
    socket = io.connect('targeturl', {
        port: 8080
    });
socket.on('connect', function () {
    console.log("socket connected"); //this is printed.
    });
socket.emit('list', {"user":'username',"token": 'mytoken'});
socket.on('message', function(data){
    console.log(data);
});

socket.on('error', function(data){
    console.log(data); //nothing is printed
});

Can anyone explain why this doesn't work?

Contributor

JulianSlzr commented Mar 6, 2014

The message event is only emitted when you use socket.send(). Furthermore, that event is emitted server-side, not client-side.

@rauchg rauchg closed this Nov 25, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment