我在我的 iOS 应用程序上使用SocketIO 项目连接到我的 node.js 服务器,一切正常,直到我选择连接到 facebook。当我连接到 Facebook 时,我向我的服务器发送了一些数据,他回答了一些数据,例如“用户已连接,用户在数据库中创建”等。之后,我的 NSInputStream 似乎为 0,因此我的连接关闭。我不知道该怎么办,我花了 14 个小时,仍然得到这个问题......
你能帮我吗?
编辑:看起来问题出在SRWebSocket.m第 1462 行
有关更多详细信息,我添加了一些日志:
case NSStreamEventHasBytesAvailable: {
SRFastLog(@"NSStreamEventHasBytesAvailable %@", aStream);
const int bufferSize = 2048;
uint8_t buffer[bufferSize];
while (_inputStream.hasBytesAvailable) {
int bytes_read = [_inputStream read:buffer maxLength:bufferSize];
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"BYTES_READ = %i", bytes_read);
});
if (bytes_read > 0) {
[_readBuffer appendBytes:buffer length:bytes_read];
} else if (bytes_read < 0) {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"ERROR = %@", _inputStream.streamError);
});
[self _failWithError:_inputStream.streamError];
}
if (bytes_read != bufferSize) {
break;
}
};
[self _pumpScanner];
break;
}
结果:
onData 5:::{"name":"initalLogin","args":[{"guid":"af78bdf0-f17d-ede2-7dd6-22708d1330f7","usedWithFaceBook":true}]}
start/reset timeout
CURRRENT SIZE = 0
READ BUFFER LENTGH = 373
event
CURRRENT SIZE = 0
BYTES_READ = 0
NSStreamEventEndEncountered <__NSCFInputStream: 0xab21660>
Reason = Stream end encountered
onDisconnect()
DECONNEXION = The operation couldn’t be completed. (SocketIOError error -4.)