steveseguin / raspberry_ninja

Publish or capture VDO.Ninja streams with Python (Raspberry Pi, Linux, Mac, Windows WSL)
https://raspberry.ninja
151 stars 30 forks source link

Exception while publishing #35

Open jcelerier opened 1 year ago

jcelerier commented 1 year ago

I just had this error after launching a publisher:

Fatal error on SSL protocol
protocol: <asyncio.sslproto.SSLProtocol object at 0x7fb8f1ee90>
transport: <_SelectorSocketTransport closing fd=28 read=idle write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/sslproto.py", line 689, in _write_appdata
    self._do_write()
  File "/usr/lib/python3.11/asyncio/sslproto.py", line 704, in _do_write
    del self._write_backlog[0]
        ~~~~~~~~~~~~~~~~~~~^^^
IndexError: deque index out of range
HANDLE ICE
HANDLE ICE
HANDLE ICE
HANDLE ICE
HANDLE ICE
data transfer failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/websockets/legacy/protocol.py", line 968, in transfer_data
    message = await self.read_message()
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/websockets/legacy/protocol.py", line 1038, in read_message
    frame = await self.read_data_frame(max_size=self.max_size)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/websockets/legacy/protocol.py", line 1113, in read_data_frame
    frame = await self.read_frame(max_size)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/websockets/legacy/protocol.py", line 1170, in read_frame
    frame = await Frame.read(
            ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/websockets/legacy/framing.py", line 69, in read
    data = await reader(2)
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/streams.py", line 728, in readexactly
    await self._wait_for_data('readexactly')
  File "/usr/lib/python3.11/asyncio/streams.py", line 522, in _wait_for_data
    await self._waiter
  File "/usr/lib/python3.11/asyncio/sslproto.py", line 689, in _write_appdata
    self._do_write()
  File "/usr/lib/python3.11/asyncio/sslproto.py", line 704, in _do_write
    del self._write_backlog[0]
        ~~~~~~~~~~~~~~~~~~~^^^
IndexError: deque index out of range
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/websockets/legacy/protocol.py", line 968, in transfer_data
    message = await self.read_message()
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/websockets/legacy/protocol.py", line 1038, in read_message
    frame = await self.read_data_frame(max_size=self.max_size)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/websockets/legacy/protocol.py", line 1113, in read_data_frame
    frame = await self.read_frame(max_size)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/websockets/legacy/protocol.py", line 1170, in read_frame
    frame = await Frame.read(
            ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/websockets/legacy/framing.py", line 69, in read
    data = await reader(2)
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/streams.py", line 728, in readexactly
    await self._wait_for_data('readexactly')
  File "/usr/lib/python3.11/asyncio/streams.py", line 522, in _wait_for_data
    await self._waiter
  File "/usr/lib/python3.11/asyncio/sslproto.py", line 689, in _write_appdata
    self._do_write()
  File "/usr/lib/python3.11/asyncio/sslproto.py", line 704, in _do_write
ON ICE CONNECTION STATE CHANGE: <enum GST_WEBRTC_ICE_CONNECTION_STATE_COMPLETED of type GstWebRTC.WebRTCICEConnectionState>
    del self._write_backlog[0]
        ~~~~~~~~~~~~~~~~~~~^^^
IndexError: deque index out of range

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/jcelerier/raspberry_ninja/publish.py", line 1631, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/jcelerier/raspberry_ninja/publish.py", line 1622, in main
    res = await c.loop()
          ^^^^^^^^^^^^^^
  File "/home/jcelerier/raspberry_ninja/publish.py", line 985, in loop
    async for message in self.conn:
  File "/usr/lib/python3/dist-packages/websockets/legacy/protocol.py", line 497, in __aiter__
    yield await self.recv()
          ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/websockets/legacy/protocol.py", line 568, in recv
    await self.ensure_open()
  File "/usr/lib/python3/dist-packages/websockets/legacy/protocol.py", line 944, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: no close frame received or sent

Don't know if it's just a transient thing as I did not see this error happen once in 4 days of tests - I could see a few frames reaching my client and then it crashed.

steveseguin commented 1 year ago

Thank you for reporting the issue.

I think I know the cause, and will try to update things to avoid it from happening again. It should be exceedingly rare though, as I only need to update the site's SSL certs every 400 days .. and that's what I think triggered that error.