Closed matthew-ceravolo closed 3 months ago
Hi @matthew-ceravolo
For the write, this was fixed yesterday and is available in this release: https://github.com/deepgram/deepgram-go-sdk/releases/tag/v1.3.2
For the read, you can't call Read()
on your own. This is handled by the SDK itself. This SDK provides a higher level of abstraction and just need to implement the callback to receive all struct response from the Deepgram endpoint.
Take a look at this example here: https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/streaming/microphone/main.go
yup, we only use the callbacks. I can DM you our code for this flow if it's helpful. I'll upgrade to 1.3.2 for the write fixes though in the meantime
and thank you for the super quick reply and help!
I would definitely update to this latest release and see how it works for you based on the expected use of the SDK.
will update now and see how it goes. and I double-checked the code to verify that 1) there arent any exposed interfaces to call Read
from directly via the Deepgram client, and 2) that we dont use the Deepgram client's Connect()
to get any websockets directly that we Read
from.
however, that Read
panic log was from 1.1.3
, so I'm sure a lot has changed since then. I'll update now and follow-up if we see it again in the future.
thanks again!
yup, we only use the callbacks. I can DM you our code for this flow if it's helpful. I'll upgrade to 1.3.2 for the write fixes though in the meantime
If you want me to take a look, I definitely can and offer some guidance. If there is an issue with the SDK, it would also help to troubleshoot. You can reach out in Discord to share code and/or discuss.
@dvonthenen - we're still seeing the same read issue on 1.3.2 (caused one panic in total in the last 2 hours, across 5 pods):
panic: repeated read on failed websocket connection
goroutine 9417 [running]:
github.com/dvonthenen/websocket.(*Conn).NextReader(0xc0007762c0)
/root/go/pkg/mod/github.com/dvonthenen/websocket@v1.5.1-dyv.2/conn.go:1030 +0x26e
github.com/dvonthenen/websocket.(*Conn).ReadMessage(0xc00079f580?)
/root/go/pkg/mod/github.com/dvonthenen/websocket@v1.5.1-dyv.2/conn.go:1093 +0x13
github.com/deepgram/deepgram-go-sdk/pkg/client/live.(*Client).listen(0xc00079f580)
/root/go/pkg/mod/github.com/deepgram/deepgram-go-sdk@v1.3.2/pkg/client/live/client.go:284 +0x245
created by github.com/deepgram/deepgram-go-sdk/pkg/client/live.(*Client).ConnectWithRetry in goroutine 9239
/root/go/pkg/mod/github.com/deepgram/deepgram-go-sdk@v1.3.2/pkg/client/live/client.go:237 +0xce7
-- for posterity: we dug into this one a bit more and agree this is separate from the concurrency issues
Connecting with you in Discord
Just putting some notes here for this issue.
Waiting for feedback on this, but internal testing looks like this is resolved. We can always reopen if that isn't the case.
There were a couple of issues resolved in PRs worth mentioning:
After resolving these issues, I think the behavior is what was intended in the design of the functionality. There were a number of examples introduced to help test these use cases. Will transform those into unit tests a little later down the road.
What is the current behavior?
from version 1.3.1:
as well as, from version 1.1.3:
Steps to reproduce
There are race conditions that arise from normal usage. We just have a stream of audio from Twilio that we pump through via:
_, err := s.speechRecognizer.Write(audio)
Expected behavior
For it to not panic - reads and writes on websockets need to be protected with mutexes. neither reads nor writes can occur simultaneously
Please tell us about your environment
Other information