Skip to content

Error upon socket connection closure #183

@roerohan

Description

@roerohan

Description

I'm using v2.11.0 of your SDK and I often run into this error in live transcriptions.

future: <Task finished name='Task-311517' coro=<LiveTranscription._start() done, defined at /usr/local/lib/python3.11/dist-packages/deepgram/transcription.py:178> exception=ConnectionClosedError(Close(code=1011, reason='Deepgram did not provide a response message within the timeout window. See https://dpgr.am/net0000'), Close(code=1011, reason='Deepgram did not provide a response message within the timeout window. See https://dpgr.am/net0000'), True)>
 
Traceback (most recent call last):
 File "/usr/local/lib/python3.11/dist-packages/deepgram/transcription.py", line 222, in _start
   await self._socket.send(body)
 File "/usr/local/lib/python3.11/dist-packages/websockets/legacy/protocol.py", line 635, in send
   await self.ensure_open()
 File "/usr/local/lib/python3.11/dist-packages/websockets/legacy/protocol.py", line 939, in ensure_open
   raise self.connection_closed_exc()

After this, none of the send() method calls on an instance of the LiveTranscription object send any data over the socket.

Debugging

It seems like the issue is here:

if self._socket.closed:

It appears that the code only checks if the socket is closed when there is a message timeout while waiting in the queue.
However, if I insert a lot of messages in the queue (by calling the send method) when self._socket.closed is False, and the socket closes later, the code will try to send the message over a closed socket at some point, resulting in the above error.

Since there is no try except block, the error also causes the while loop to exit, and therefore I'm not able to send any more messages using that object.

Metadata

Metadata

Assignees

Labels

legacy-releasesThese are issues for previous versions of the SDK not in active maintenance and support.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions