任何人都可以帮助我与我的python WebSockets服务器出于某种原因每当我试图发送JSON数据有很多错误,这里是我的代码链接:
http://textuploader.com/v5kn我的客户端自上次更新以来没有更改,并且在连接到服务器后没有发送任何内容,因此应该没问题。
错误如下:
connection established ('127.0.0.1', 51777)
Handshaking...
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 51429)
Traceback (most recent call last):
File "C:Python27libSocketServer.py", line 599, in process_request_thread
self.finish_request(request, client_address)
File "C:Python27libSocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:Python27libSocketServer.py", line 655, in __init__
self.handle()
File "C:/Users/Heslop/Desktop/Projects/SnakeServer/server.py", line 64, in handle
self.read_next_message()
File "C:/Users/Heslop/Desktop/Projects/SnakeServer/server.py", line 68, in read_next_message
length = ord(self.rfile.read(2)[1]) & 127
IndexError: string index out of range
事实上,您可以尝试为您进行servide - clientside msg(frame
)编码和解码的第三个库,这样您就可以专注于应用程序构建。
这是我的小包装:https://github.com/HelloLyfing/py-websocket-helper
因为我是唯一一个使用过这个包装的人,所以如果你有任何问题,请告诉我。