-
-
Notifications
You must be signed in to change notification settings - Fork 573
Closed
Description
For getting to know the websockets package, I started with a very minimal example with fails with an ConnectionClosedError after ~10 s.
I'm using Python 3.7.
I suspected, that there might be somewhere a timeout, but I haven't found anything. As far as I understood the docs, the connection should stay alive?
server.py
import websockets
import asyncio
async def main(ws, _):
while(True):
msg = await ws.recv()
print(msg)
start_server = websockets.serve(main, "localhost", "1236")
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()client.py
import asyncio
import websockets
async def main():
uri = "ws://localhost:1236"
async with websockets.connect(uri) as ws:
while True:
await ws.send(input())
asyncio.get_event_loop().run_until_complete(main())The full error reads
Error in connection handler
Traceback (most recent call last):
File "***lib/python3.7/site-packages/websockets/protocol.py", line 827, in transfer_data
message = await self.read_message()
File "***lib/python3.7/site-packages/websockets/protocol.py", line 895, in read_message
frame = await self.read_data_frame(max_size=self.max_size)
File "***lib/python3.7/site-packages/websockets/protocol.py", line 971, in read_data_frame
frame = await self.read_frame(max_size)
File "***lib/python3.7/site-packages/websockets/protocol.py", line 1051, in read_frame
extensions=self.extensions,
File "***lib/python3.7/site-packages/websockets/framing.py", line 105, in read
data = await reader(2)
File "***lib/python3.7/asyncio/streams.py", line 679, in readexactly
await self._wait_for_data('readexactly')
File "***lib/python3.7/asyncio/streams.py", line 473, in _wait_for_data
await self._waiter
concurrent.futures._base.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "***lib/python3.7/site-packages/websockets/server.py", line 191, in handler
await self.ws_handler(self, path)
File "/home/juergen/projects/poker/src/server/min_ex_server2.py", line 14, in main
msg = await ws.recv()
File "***lib/python3.7/site-packages/websockets/protocol.py", line 509, in recv
await self.ensure_open()
File "***lib/python3.7/site-packages/websockets/protocol.py", line 812, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason
Metadata
Metadata
Assignees
Labels
No labels