deepgram / deepgram-dotnet-sdk

.NET SDK for Deepgram's automated speech recognition APIs.
https://developers.deepgram.com
MIT License
28 stars 32 forks source link

LiveTranscriptionClient.StartConnectionAsync() fails on netstandard2.0 #62

Closed lmerino-ep closed 1 year ago

lmerino-ep commented 1 year ago

What is the current behavior?

Any call to LiveTranscriptionClient.StartConnectionAsync() raises an ArgumentException after setting the header User-Agent

"System.ArgumentException: 'The 'User-Agent' header must be modified with the appropriate property or method."

Steps to reproduce

This call raises the exception: _clientWebSocket.Options.SetRequestHeader("User-Agent", Helpers.GetUserAgent());

Please tell us about your environment

We want to make sure the problem isn't specific to your operating system or programming language.

Using the sdk targeting netstandard2.0 from a c# WinForms app based on .net framework 4.8, running in windows 10.

Other information

This is a quick fix, but the User-Agent header is not added:

if NETSTANDARD2_0

if (!WebHeaderCollection.IsRestricted("User-Agent")) { _clientWebSocket.Options.SetRequestHeader("User-Agent", Helpers.GetUserAgent()); }

endif

It could be a bug in .net framework as is stated here: https://stackoverflow.com/questions/15894844/how-can-i-set-user-agent-and-referer-headers-when-using-clientwebsocket-in-net https://github.com/dotnet/runtime/issues/24822#issuecomment-391472613

This bug doesn't allow the User-Agent header to be added to the request.

LeeKevinXO commented 1 year ago

Could I ask how I place 'the quick fix' into my project? This quick fix means that I have to modify the source code, right? and re-compile it?

lmerino-ep commented 1 year ago

That's right. You have to modify the source and recompile. But, before doing that, you should try using the last version of the nuget.

LeeKevinXO commented 1 year ago

Thank you sooo much. StartStreamAsync is working now but another error came next ... and what is NET-0001 error? I searched a lot, no clues however.

LeeKevinXO commented 1 year ago

I'm in Tokyo. Is it because the connection is instable from the location of servers to Tokyo?

lukeocodes commented 1 year ago

Hey! https://developers.deepgram.com/reference/streaming#:~:text=By%20default%2C%20the%20Deepgram%20streaming,the%20client%20for%2012%20seconds.

Here is some info on NET-0001 errors