-
-
Notifications
You must be signed in to change notification settings - Fork 575
Closed
Labels
Description
We are attempting to transfer a file of 1 gigabyte via websockets and have been running into the following error:
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x92\xbb\x85linux\x84imx8\x93\x80', rsv1=False, rsv2=False, rsv3=False)
2023-05-17 10:41:57,717:[cli_network]:[INFO]:: 100% sent
2023-05-17 10:41:57,717:[websockets.protocol]:[DEBUG]:: client > Frame(fin=True, opcode=0, data=b'', rsv1=False, rsv2=False, rsv3=False)
2023-05-17 10:41:57,722:[cli_network]:[INFO]:: Waiting for daemon response...
2023-05-17 10:44:22,278:[websockets.protocol]:[DEBUG]:: client - event = eof_received()
2023-05-17 10:44:22,290:[websockets.protocol]:[DEBUG]:: client ! failing OPEN WebSocket connection with code 1006
2023-05-17 10:44:22,291:[websockets.protocol]:[DEBUG]:: client - event = connection_lost(None)
2023-05-17 10:44:22,292:[websockets.protocol]:[DEBUG]:: client - state = CLOSED
2023-05-17 10:44:22,293:[websockets.protocol]:[DEBUG]:: client x code = 1006, reason = [no reason]
Traceback (most recent call last):
File "/.venv/lib/python3.8/site-packages/websockets/protocol.py", line 827, in transfer_data
message = await self.read_message()
File "/.venv/lib/python3.8/site-packages/websockets/protocol.py", line 895, in read_message
frame = await self.read_data_frame(max_size=self.max_size)
File ".venv/lib/python3.8/site-packages/websockets/protocol.py", line 971, in read_data_frame
frame = await self.read_frame(max_size)
File "/.venv/lib/python3.8/site-packages/websockets/protocol.py", line 1047, in read_frame
frame = await Frame.read(
File ".venv/lib/python3.8/site-packages/websockets/framing.py", line 105, in read
data = await reader(2)
File "/Users/lamathe/brazil-pkg-cache/packages/CPython38Runtime/CPython38Runtime-release.309865.0/AL2_x86_64/DEV.STD.PTHREAD/build/python3.8/lib/python3.8/asyncio/streams.py", line 721, in readexactly
raise exceptions.IncompleteReadError(incomplete, n)
asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 2 expected bytes
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "cli.py", line 31, in <module>
run(
File "cli.py", line 21, in run
Cli(
File "/.venv/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/.venv/lib/python3.8/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/.venv/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/.venv/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File ".venv/lib/python3.8/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "_Cli.py", line 43, in wrapper
return loop.run_until_complete( # type: ignore[misc]
File ".venv/lib/python3.8/site-packages/nest_asyncio.py", line 70, in run_until_complete
return f.result()
File "CPython38Runtime/CPython38Runtime-release.309865.0/AL2_x86_64/DEV.STD.PTHREAD/build/python3.8/lib/python3.8/asyncio/futures.py", line 178, in result
raise self._exception
File "CPython38Runtime/CPython38Runtime-release.309865.0/AL2_x86_64/DEV.STD.PTHREAD/build/python3.8/lib/python3.8/asyncio/tasks.py", line 280, in __step
result = coro.send(None)
File "cli.py", line 92, in run
await deploy_artifact(console, payload, send, debug)
File "cli.py", line 112, in deploy_artifact
raise e
File "cli.py", line 108, in deploy_artifact
message_type, message = await send("deploy", payload, True, progress_callback)
File "network.py", line 82, in _connect_send_receive
response = await websocket.recv()
File "venv/lib/python3.8/site-packages/websockets/protocol.py", line 509, in recv
await self.ensure_open()
File ".venv/lib/python3.8/site-packages/websockets/protocol.py", line 803, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason
Client side code:
async def _connect_send_receive(
data: bytes, receive: bool, callback: typing.Optional[progress_callback] = None
) -> typing.Optional[typing.Tuple[str, object]]:
uri: str = _get_uri()
_logger.debug(f"Connecting to {uri}")
max_size: int = typing.cast(int, None)
max_timeout: float = typing.cast(float, None)
if callback:
callback(0, CHUNK_SIZE_BYTES, len(data))
fragmented_data = _get_fragmented_data(data, callback)
async with websockets.connect(
uri,
max_size=max_size,
ping_timeout=max_timeout,
compression=None,
ping_interval=max_timeout,
max_queue=max_size,
) as websocket:
_logger.info("Sending message to daemon...")
await websocket.send(fragmented_data)
if receive:
_logger.info("Waiting for daemon response...")
response = await websocket.recv()
decoded_msg = typing.cast(
typing.Dict[str, object], simpleion.loads(response) # type: ignore[misc]
)
_logger.debug(f"Received message of type: {decoded_msg['type']}")
return typing.cast(str, decoded_msg["type"]), decoded_msg["message"]
return None
Daemon side code:
async def init_server(self) -> websockets.WebSocketServer:
self._ws_server_sync = await websockets.serve(
self._serve,
self._host,
self._port_server1,
max_size=None, # type: ignore[arg-type]
ping_timeout=None, # type: ignore[arg-type]
ping_interval=None, # type: ignore[arg-type]
compression=None,
max_queue=None, # type: ignore[arg-type]
)
return self._ws_server_sync
async def _serve(self, socket: websockets.WebSocketServerProtocol, path: str) -> None:
self._websocket = socket
msg: typing.Union[str, bytes] = await self._websocket.recv()
decoded_msg = typing.cast(MessageObject, simpleion.loads(msg)) # type: ignore[misc]
# do something
Have set both ping_timeout and ping_interval to None. Wondering what could help here?