문제

I'm using the default example provided in the https://github.com/pkyeck/socket.IO-objc GitHub repo. And SocketIO throws an error that the handshake failed and the server returned with status code 400. I have successfully connected to the server with the socket.io Javascript library.

- (void) viewDidLoad
{
    [super viewDidLoad];
    socketIO = [[SocketIO alloc] initWithDelegate:self];
    socketIO.useSecure = YES;

    [socketIO connectToHost:@"[url]" onPort:443];
}

-

SocketTesterARC[2457:60b] Connecting to socket with URL: https://[url]:443/socket.io/1/?t=1397682804193

SocketTesterARC[2457:60b] didReceiveResponse() 400
SocketTesterARC[2457:60b] ERROR: handshake failed ... Server returned status code 400

SocketTesterARC[2457:60b] onError() Error Domain=SocketIOError Code=-6 "Error Domain=SocketIOError Code=400 "Server returned status code 400" UserInfo=0x1780718c0 {NSLocalizedDescription=Server returned status code 400}" UserInfo=0x178072740 {NSLocalizedDescription=Error Domain=SocketIOError Code=400 "Server returned status code 400" UserInfo=0x1780718c0 {NSLocalizedDescription=Server returned status code 400}}
도움이 되었습니까?

해결책

Check the version number, guess you are using version 0.9, your server side code using version 1.0. Both server and client should be in same version.

다른 팁

I also had such error when hard-coded my Mac's IP into iOS app code. Once I have dynamic IP, one day it has been changed and - pfff - handshake error and timeout.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top