我在我的iOS应用程序上使用SocketIO project连接到我的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.)