Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

client not handshaken client should reconnect #120

Open
ngzhongcai-zz opened this issue Aug 14, 2013 · 5 comments
Open

client not handshaken client should reconnect #120

ngzhongcai-zz opened this issue Aug 14, 2013 · 5 comments

Comments

@ngzhongcai-zz
Copy link

#69 #77

May be related to above two, but I am opening another ticket here anyways.
At the back, I am running multiple socket.io servers with Haproxy in the front.
If I were to forcefully pull the plug on one of the socket.io servers, Haproxy will route connection to another socket.io server.

Issue1: SocketDidDisconnect is not fired
Issue2: I keep getting client not handshaken client should reconnect on the sio server
Issue3: On iOS side, I get a string of "onData 7:::1+0".

So I tried to modify the code by "[self disconnectForced]" at "onData 7:::1+0", and then reconnecting again. Fresh connection is made, but I am still getting the barrage of "client not handshaken client should reconnect", in addition to the fresh connection made.

Any ideas?

@ngzhongcai-zz
Copy link
Author

case 7: {
DEBUGLOG(@"error");
if([packet.data isEqualToString:@"1+0"]) {
[self disconnectForced];
}
}

@ngzhongcai-zz
Copy link
Author

But still getting a string of "warn - client not handshaken client should reconnect" on server side

@ngzhongcai-zz
Copy link
Author

did some time profiling, "checkAndStartPoll" from SocketIOTransportXHR was still firing after "[self disconnectForced]"

@ngzhongcai-zz
Copy link
Author

It's quite dirty...
I made 2 modifications.

  1. In SocketIO.m, I added
    "case 7: {
    DEBUGLOG(@"error");
    if([packet.data isEqualToString:@"1+0"]) {
    [self disconnectForced];
    }
    }" to "onData:(NSString *)data"
  2. In SocketIOTransportXHR.m, I added
    "if(![message isEqualToString:@"7:::1+0"]) {
    [self checkAndStartPoll];
    }"
    to "connectionDidFinishLoading:(NSURLConnection *)connection"

This stops it client from bombarding the server with "client not handshaken client should reconnect".
But hoping for more cleaner fix?

@tybro0103
Copy link

I'm hosting on Heroku so I have to use long polling, and I ran into the same issue. I think your fix is as clean as it can be without significantly modifying things.

I wanted to automatically reconnect in this situation so I added this to SocketIO.m:

-(void) reconnect {
    [self connectToHost:self.host onPort:self.port];
}

and call it after disconnectForced:

if([packet.data isEqualToString:@"1+0"]) {
    [self disconnectForced];
    [self reconnect];
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants