我使用https://github.com/pkyeck/socket.IO-objc GitHub回购中提供的默认示例。并且SocketIO抛出一个错误,即握手失败并且服务器返回状态码为400.我已经使用socket.io Javascript库成功连接到服务器。请帮助提前感谢。
代码..
socketIO = [[SocketIO alloc] initWithDelegate:self];
[socketIO connectToHost: @"localhost" onPort:3000];
- (void) socketIODidConnect:(SocketIO *)socket{
NSLog(@"socket.io connected.");
}
# pragma mark socket.IO-objc delegate methods
- (void) socketIO:(SocketIO *)socket didReceiveEvent:(SocketIOPacket *)packet{
NSLog(@"didReceiveEvent()");
}
- (void) socketIO:(SocketIO *)socket onError:(NSError *)error{
NSLog(@"onError() %@", error);
}
- (void) socketIODidDisconnect:(SocketIO *)socket disconnectedWithError:(NSError *)error{
NSLog(@"socket.io disconnected. did error occur? %@", error);
}
错误消息
2017-02-23 10:44:50.674聊天[940:25247]使用URL连接套接字: http://localhost:3000/socket.io/1/?t=1487826890674 2017-02-23 10:44:50.747聊天[940:25247] didReceiveResponse()400 2017-02-23 10:44:50.750聊天[940:25247]错误:握手失败...服务器 返回状态码400