Keep connection alive #206
-
How I can keep the connection alive with deepgram? I am using Django as backend and django-channels to connect with deepgram service. I have this code:
I hope that you can help me |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Deepgram has some timeouts if you don't send any audio for a while (10s) - however, if you don't have audio to send during that time, we have a new feature that allows you to keep the connection alive. Sending a text message with the following JSON: |
Beta Was this translation helpful? Give feedback.
-
You mean that I have to send some like that ?
|
Beta Was this translation helpful? Give feedback.
Hey @Fernando473, instead of replacing
self.socket
, you want to send a message to that existing socket/connection.So you can run
self.socket.send({"type": "KeepAlive"})
every 5-10 seconds to keep the connection open. When you're ready to close the connection, you can runself.socket.send({"type": "CloseStream"})
.