objective -c SocketIO客户端无法连接到gevent-socketIO服务器

时间:2014-01-25 10:47:12

标签: objective-c websocket socket.io gevent-socketio django-socketio

我正在使用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() 

DJANGO LOG

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

那么这里有什么问题?

on the cliend

- (void) socketIODidConnect:(SocketIO *)socket{}

永远不会被调用。 几秒钟后程序总会跳到下面。

- (void) socketIODidDisconnect:(SocketIO *)socket disconnectedWithError:(NSError *)error{}  

1 个答案:

答案 0 :(得分:0)

无赖!!我的SocketIO.m和SRWebSocket.m文件被修改以修复某些警告,显然这会破坏socketIO代码......使用原始文件后,问题就解决了。现在我想把脸砸到键盘上..