Skip to content
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

Problems connecting with second transport after first fails. #1035

Closed
jfgorski opened this issue Sep 19, 2012 · 1 comment
Closed

Problems connecting with second transport after first fails. #1035

jfgorski opened this issue Sep 19, 2012 · 1 comment

Comments

@jfgorski
Copy link

I think there's a bug in socket.io 0.9.10 lib/manager.js and sending the connect packet on the second transport after the first fails. E.g. if websocket fails to connect for some reason, then xhr-polling will not have the connect packet sent from server to browser since the server only sends it on the first transport for the same session-id. The patch that seems to fix it is

@@ -666,6 +666,7 @@
return;
}
if (handshaken) {
+var t0 = this.transports[data.id];
if (transport.open) {
if (this.closed[data.id] && this.closed[data.id].length) {
transport.payload(this.closed[data.id]);
@@ -706,6 +709,21 @@
self.onClientDisconnect(data.id, reason);
});
}
+else // matches "if (!this.connected[data.id])"
+{
+var t1 = transport;

  • // when transport changes, send the connect packet on the new transport
  • if (t1&&t0&&t1.transport!==t0.transport)
  •  for (var i in this.namespaces) {
    
  •    if (this.namespaces.hasOwnProperty(i)) {
    
  •      // echo back connect packet and fire connection event
    
  •      if (i === '') {
    
  •        this.namespaces[i].handlePacket(data.id, { type: 'connect' });
    
  •      }
    
  •    }
    
  •  }
    
    +}
    } else {
    if (transport.open) {
    transport.error('client not handshaken', 'reconnect');
@jfgorski
Copy link
Author

Btw a simple way to get websocket to fail so the next transport is tried is to skip sending the connect packet, e.g. like this in lib/manager.js:

// echo back connect packet and fire connection event
if (i === '') {
+if (transport.transport!='websocket')
this.namespaces[i].handlePacket(data.id, { type: 'connect' });
}

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant