io.emit causes 4undefined frame #2590

nitin02 opened this Issue Jun 19, 2016 · 6 comments


None yet

2 participants

nitin02 commented Jun 19, 2016

The nodejs servers are set up on AWS EC2 instances with Nginx as the primary load balancer. I'm implementing a the concept of "rooms" with 's redis adapter and found no work around for this issue.

I can see from my chrome's "network" tab in debug mode that, it switches to websocket. In the Frame's tab of the web socket, I can see all the information sent to and back from the nodejs server.

Any operation with socket.emit is proper and returns the proper object as 4["actual_content"] frame and is received by the client but any operation with io object (all operation done with io) returns a 4undefined frame.

Please note that, there seems to be no code issue as the same setup works perfectly when implemented locally on my machine.

Thank you for your help.

MasterJames commented Jun 19, 2016 edited

I'm thinking you should simplify the problem to a code sample you're comfortable with posting.
If you use io.on "connection" it's the handler you pass that can see its argument the socket for emit etc. So it's probably the expected behaviour for io.on to return undefined as a result, no?
I'm sure you know that so I must not be seeing clearly in this moment.

Are you fully updated? Talking about Engine.IO ?

When you require ("")( do you pass a port? ) or arguments?
Call attach?

nitin02 commented Jun 19, 2016

Simplified, this is what I am doing,

var app = require('express')();
var http = require('http').Server(app);
var io = require('')(http);

http.listen(3000, function(){
  console.log('listening on *:3000');

The below code works, I am able send back to the client using the socket object.

io.on('connection', function(socket){
  socket.broadcast.emit('update', 'hello world');
// or any type of operation with socket works, for example: socket.emit('news', 'hello world' );

However, the below causes 4undefined frame.'news').emit('update', 'hello world');

or any type of operation using the io object,

For example:

io.sockets.emit('update', 'hello world');
io.emit('update', 'hello world');

I've tried using the latest version of (v1.4.6). Do note that the same code works locally.

MasterJames commented Jun 20, 2016 edited

Do you put the "to" inside the on 'connection' ?
no of course not. Maybe this is helpful if it's originating from some client and they don't need to see it themselves? (oh you are using that, right)
as opposed to
socket.emit('update', {room: 'news', mssg: 'update world'});

MasterJames commented Jun 20, 2016 edited

Does it change if you force long-polling?
io.set('transports', ['jsonp-polling']);

or maybe

io.configure(function () { 
      io.set("transports", ["xhr-polling"]); 
      io.set("polling duration", 10); 

Not as a solution just checking for possible reasons.

I'm guessing some port is blocked. Maybe try a different port like 4321? (oh right 3000 how about 80 then?)
Who is the provider?

Can you access this from both ends?

Heavier document saying Proxies can cause problems etc.

MasterJames commented Jun 20, 2016 edited

Well if your on AWS using ELB this might be useful. It might be what's happening wherever you are hosting.

Another link that might help

This Chrome plugin might be useful too

You can also do this in the browser for extra debugging info.
localStorage.debug = '*'
gives more detail like...

update: good bye world 6 writing packet {"type":2,"data":["got",{"mssg":"update"}],"options":{"compress":true},"nsp":"/"} +1ms encoding packet {"type":2,"data":["got",{"mssg":"update"}],"options":{"compress":true},"nsp":"/"} +2ms encoded {"type":2,"data":["got",{"mssg":"update"}],"options":{"compress":true},"nsp":"/"} as 2["got",{"mssg":"update"}] +1ms flushing 1 packets in socket +19ms writing ping packet - expecting pong within 60000ms +11s flushing 1 packets in socket +0ms socket receive: type "pong", data "undefined" +4ms

Then you can get a break point into the stack at some point like the log and try to trace in there that way.

I guess you could dig further by trying this snippet in Engine.IO the Client code.

nitin02 commented Jun 20, 2016

Thank you for your exhaustive and wonderful list of solutions and tips.

However, After much search I was able to pin-point the error to the issue below by printing and,


This seems to be a known consequence of the latest versions of This issue is still open (2405) and will be resolved in the next release (maybe). They should at least point this out somewhere, considering that this a serious issue.

So, Manually degrading 1.3.* did the trick. All is working well.

(On a side note, I am still puzzled as to why only operations on socket worked properly previously as the above issue should have broken that functionality too. Weird!)

Thank you for your time.

@nitin02 nitin02 closed this Jun 20, 2016
@gmazlami gmazlami added a commit to probr/probr-analysis that referenced this issue Oct 17, 2016
@gmazlami gmazlami Use fixed npm dependency versions for socketio to avoid connections i… dd024dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment