You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was setting up the realtime API for voice chatting, but I found after my first question and reply from the model, the web socket would close and terminate the conversation. (This was while using CreateServerVoiceActivityTurnDetectionOptions)
When calling ReceiveUpdatesAsync to receive server messages, I didn't expect this to close the _clientWebSocket, but it did.
It took me a while to figure out that the AsyncWebsocketMessageResultEnumerator is automatically disposing of the _clientWebSocket when it finishes iterating, causing ReceiveUpdatesAsync to terminate the WebSocket. Commenting out the disposing call within AsyncWebsocketMessageResultEnumerator resulted in the expected behavior for me:
This allowed me to have my expected 2-way conversation. If there's another intended method to receive server events without terminating the socket, or to keep the socket alive for more than one request-response, please let me know.
Steps to reproduce
Initialize a RealtimeConversationSession with server voice activity turn detection:
Begin handling server responses with ReceiveUpdatesAsync in a loop:
while(true){awaitforeach(varupdateinsession.ReceiveUpdatesAsync(token)){//Handle received updates}}
Make an audible request to the AI, and wait for its response to complete. On the second loop, ReceiveUpdatesAsync will throw a System.ObjectDisposedException:
Cannotaccess a disposed object.Object name: 'System.Net.WebSockets.ClientWebSocket'.
Code snippets
No response
OS
winOS
.NET version
.NET 8 Core
Library version
2.1.0-beta.1
The text was updated successfully, but these errors were encountered:
I am having the same issue. Because the AsyncWebsocketMessageResultEnumerator disposes the client websocket, I cannot do anything with the websocket after iterating through the responses. I don't think AsyncWebsocketMessageResultEnumerator should be responsible for disposing the client websocket because it doesn't create it. the RealtimeConversationSession class should solely be responsible for this, IMO
Service
OpenAI
Describe the bug
I was setting up the realtime API for voice chatting, but I found after my first question and reply from the model, the web socket would close and terminate the conversation. (This was while using
CreateServerVoiceActivityTurnDetectionOptions
)When calling
ReceiveUpdatesAsync
to receive server messages, I didn't expect this to close the_clientWebSocket
, but it did.It took me a while to figure out that the
AsyncWebsocketMessageResultEnumerator
is automatically disposing of the_clientWebSocket
when it finishes iterating, causingReceiveUpdatesAsync
to terminate the WebSocket. Commenting out the disposing call withinAsyncWebsocketMessageResultEnumerator
resulted in the expected behavior for me:This allowed me to have my expected 2-way conversation. If there's another intended method to receive server events without terminating the socket, or to keep the socket alive for more than one request-response, please let me know.
Steps to reproduce
RealtimeConversationSession
with server voice activity turn detection:SendAudioAsync
(in my case with NAudio Wave):ReceiveUpdatesAsync
in a loop:ReceiveUpdatesAsync
will throw aSystem.ObjectDisposedException
:Code snippets
No response
OS
winOS
.NET version
.NET 8 Core
Library version
2.1.0-beta.1
The text was updated successfully, but these errors were encountered: