deepgram-python-sdk icon indicating copy to clipboard operation
deepgram-python-sdk copied to clipboard

Error: keepalive ping timeout; no close frame received

Open roerohan opened this issue 1 year ago • 6 comments

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.

roerohan avatar Feb 29 '24 10:02 roerohan

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.

davidvonthenen avatar Feb 29 '24 14:02 davidvonthenen

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

davidvonthenen avatar Mar 05 '24 15:03 davidvonthenen

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

ToxicityMax avatar Mar 06 '24 08:03 ToxicityMax

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.

davidvonthenen avatar Mar 06 '24 14:03 davidvonthenen

@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.

rutvik106 avatar Mar 26 '24 16:03 rutvik106

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

davidvonthenen avatar Mar 26 '24 17:03 davidvonthenen

Still getting this issue when using websocket with deepgram-sdk==3.7.3 using both listen and speak options. Especially since the upgrade to 3.7.3.

prismvineeth avatar Oct 12 '24 21:10 prismvineeth

Is this taken care of in Python SDK ?

prismvineeth avatar Oct 12 '24 21:10 prismvineeth

Is this taken care of in Python SDK ?

Ping/pong messages are handled using the lower level websocket library (and is present automatically. In other words, enabled by default).

davidvonthenen avatar Oct 12 '24 21:10 davidvonthenen

Still getting this issue when using websocket with deepgram-sdk==3.7.3 using both listen and speak options. Especially since the upgrade to 3.7.3.

This is typically due to a mismatch between the actual audio stream encoding/bytes being sent and the encoding and/or sample_rate values set in the options. This is definitely working correctly, and I would invite you to run the example in the repo: https://github.com/deepgram/deepgram-python-sdk/blob/main/examples/speech-to-text/websocket/http/main.py

davidvonthenen avatar Oct 12 '24 21:10 davidvonthenen