deepgram / deepgram-python-sdk

Official Python SDK for Deepgram's automated speech recognition APIs.
https://developers.deepgram.com
MIT License
178 stars 48 forks source link

Error: keepalive ping timeout; no close frame received #326

Open roerohan opened 4 months ago

roerohan commented 4 months ago

What is the current behavior?

I get the following error intermittently while sending audio packets over the deepgram socket connection.

sent 1011 (internal error) keepalive ping timeout; no close frame received

This is often followed by the log

[SSL: APPLICATION_DATA_AFTER_CLOSE_NOTIFY] application data after close notify (_ssl.c:2706)

Steps to reproduce

# Code to check if the socket connection is live
while len(self._speech_buffer):
    await self.deepgram_live._socket.send(self._speech_buffer.pop(0))
    logger.debug("Sent speech from {}", self.peer_id)

P.S. the reason why I'm using the _socket object is that I'm using deepgram-sdk==2.11.0 and I had reported an issue in the past with this version. As you mentioned, the issue was fixed in a new major version, but we haven't gotten around to updating it since it had been working fine for us all this while.

Expected behavior

The socket connection should not close abruptly.

Please tell us about your environment

Operating System/Version: Linux 5.10.209-198.812.amzn2.x86_64 (AWS Ubuntu) Python Version: 3.10.12

Other information

This error only occurs once in a while, and most often when there are multiple parallel socket connections to deepgram live.

dvonthenen commented 4 months ago

For this issue, the socket isn't receiving any data nor the keepalive message. That is expected behavior, but the SSL error is of concern. I don't have enough experience with the older version, so I will need to take some time to look at it.

PS: I re-opened this issue https://github.com/deepgram/deepgram-python-sdk/issues/183 in order to take a look at it, but not sure when I am going to get time as I have a bunch of things on my plate.

dvonthenen commented 3 months ago

@SandraRodgers said she would take a look at this issue and the other one since she has more knowledge about the v2 client.

ToxicityMax commented 3 months ago

We recently migrated to v3 and implemented the flag options={"keepalive": "true"} in DeepgramClientOptions to maintain websocket connections. However, we're encountering the same persistent issue where, intermittently, the following error floods the logs, leading to a disruption in receiving transcripts:

This error seems to occur occasionally, but once it starts, it prevents us from receiving any further transcripts through that connection. Despite setting the keepalive flag, this issue persists.

It would be helpful if there are specific troubleshooting steps or additional configurations we should consider to mitigate this issue

dvonthenen commented 3 months ago

We recently migrated to v3 and implemented the flag options={"keepalive": "true"} in DeepgramClientOptions to maintain websocket connections. However, we're encountering the same persistent issue where, intermittently, the following error floods the logs, leading to a disruption in receiving transcripts:

Hi @ToxicityMax This reported issue is for v2 of the SDK. If you are having problems with v3, reach out to discuss in Discord or create a new issue. Before you do, please update to the latest v3.1.7 of the SDK.

rutvik106 commented 3 months ago

@ToxicityMax any success with this. I too get "WebSocketException: received 1011 (internal error) Deepgram did not receive audio data or a text message within the timeout window. See https://dpgr.am/net0001; then sent 1011 (internal error) Deepgram did not receive audio data or a text message within the timeout window. See https://dpgr.am/net0001" even if keep alive is passed as true.

dvonthenen commented 3 months ago

Hi @rutvik106

If this is for v3 and you are having problems, please create another issue since this issue is specifically for v2.

Since we get this question a lot, here are some examples to demonstrate expected failures when not using and also how to utilize the feature: correctly https://github.com/deepgram/deepgram-python-sdk/pull/348