Skip to content

Commit

Permalink
close the ws unless the ws is disconnected (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajar98 authored Jul 24, 2023
1 parent 0afcc00 commit 6983a23
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vocode/streaming/telephony/conversation/vonage_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,17 @@ async def attach_ws_and_start(self, ws: WebSocket):
from_phone_number=self.from_phone,
)
)
disconnected = False
while self.active:
try:
chunk = await ws.receive_bytes()
self.receive_audio(chunk)
except WebSocketDisconnect:
self.logger.debug("Websocket disconnected")
disconnected = True
break
if not disconnected:
await ws.close()
await self.config_manager.delete_config(self.id)
await self.tear_down()

Expand Down

0 comments on commit 6983a23

Please sign in to comment.