我正在使用 object-c socketio( https://github.com/pkyeck/socket.IO-objc ) 连接到我的 gevent-socketIO 服务器,它适用于我的网页。
客户
[self.socketIO connectToHost:SOCKET_URL onPort:SOCKET_PORT];
服务器
def socketio(request):
logger.info("Connecting start")
socketio_manage(
request.environ,
{'': BigSpoonNamespace, },
request=request
)
logger.info("Connecting finish")
return HttpResponse()
DJ 日志
2014-01-25 18:21:01,499 [DEBUG] socketio.virtsocket: Spawning sub-Socket Greenlet: send_into_ws 2014-01-25 18:21:01,500 [DEBUG] socketio.virtsocket: Spawning sub-Socket Greenlet: read_from_ws 2014-01-25 18:21:01,500 [DEBUG] socketio.virtsocket: Spawning sub-Socket Greenlet: _heartbeat 2014-01-25 18:21:01,500 [DEBUG] socketio.virtsocket: Spawning sub-Socket Greenlet: _heartbeat_timeout 2014-01-25 18:21:01,502 [INFO] root: Connecting start 2014-01-25 18:22:01,525 [DEBUG] socketio.virtsocket: heartbeat timed out, killing socket 2014-01-25 18:22:01,526 [DEBUG] socketio.virtsocket: Removing sessid='64962840572' client_queue[1] server_queue[1] hits=1 from
服务器套接字 2014-01-25 18:22:01,542 [INFO] root: 连接完成
NGINX 日志
Traceback (most recent call last):
File "/home/ec2-user/webapps/2013-final-project-7/src/backend/env/lib/python2.6/site-packages/gevent/greenlet.py", line 327, in run
result = self._run(*self.args, **self.kwargs)
File "/home/ec2-user/webapps/2013-final-project-7/src/backend/env/src/gevent-socketio-master/socketio/transports.py", line 259, in read_from_ws
message = websocket.receive()
File "/home/ec2-user/webapps/2013-final-project-7/src/backend/env/src/gevent-websocket-master/geventwebsocket/websocket.py", line 296, in receive
result = self._receive()
File "/home/ec2-user/webapps/2013-final-project-7/src/backend/env/src/gevent-websocket-master/geventwebsocket/websocket.py", line 273, in _receive
raise WebSocketError('Received invalid close frame: %r %r' % (code, self.close_message))
WebSocketError: Received invalid close frame: 65535 bytearray(b'')
<Greenlet at 0x3340550: read_from_ws> failed with WebSocketError
那么这里有什么问题呢?
在客户端
- (void) socketIODidConnect:(SocketIO *)socket{}
永远不会被调用。并且程序总是在几秒钟后跳转到以下内容。
- (void) socketIODidDisconnect:(SocketIO *)socket disconnectedWithError:(NSError *)error{}