deepgram/deepgram-dotnet-sdk

LiveTranscriptionClient.StartConnectionAsync() fails on netstandard2.0

Closed this issue · 5 comments

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
dotnet/runtime#24822 (comment)

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

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?

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.

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.

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