socket.IO-objc
socket.IO-objc copied to clipboard
client not handshaken client should reconnect
#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?
case 7: { DEBUGLOG(@"error"); if([packet.data isEqualToString:@"1+0"]) { [self disconnectForced]; } }
But still getting a string of "warn - client not handshaken client should reconnect" on server side
did some time profiling, "checkAndStartPoll" from SocketIOTransportXHR was still firing after "[self disconnectForced]"
It's quite dirty... I made 2 modifications.
- In SocketIO.m, I added "case 7: { DEBUGLOG(@"error"); if([packet.data isEqualToString:@"1+0"]) { [self disconnectForced]; } }" to "onData:(NSString *)data"
- 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?
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];
}