Skip to content

Commit a9b8125

Browse files
committed
fix: Websocket connections should be closed on any error
1 parent 3f35feb commit a9b8125

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/ex_azure_speech/speech_to_text/websocket.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ defmodule ExAzureSpeech.SpeechToText.Websocket do
105105
{:ok, _} <- update_connection_context(pid),
106106
{:ok, _} <- start_stream(pid) do
107107
{:ok, stream_responses(pid, close_connection_callback)}
108+
else
109+
err ->
110+
close_connection_callback.(pid)
111+
err
108112
end
109113
end
110114

lib/ex_azure_speech/text_to_speech/websocket.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ defmodule ExAzureSpeech.TextToSpeech.Websocket do
115115
{:ok, _} <- update_connection_context(pid),
116116
{:ok, _} <- start_synthesis(pid, command) do
117117
{:ok, stream_responses(pid, close_connection_callback)}
118+
else
119+
err ->
120+
close_connection_callback.(pid)
121+
err
118122
end
119123
end
120124

0 commit comments

Comments
 (0)