deepgram/deepgram-dotnet-sdk

A customer reported that it's not possible to set the HTTP Timeout at all now.

Closed this issue · 7 comments

          A customer reported that it's not possible to set the HTTP Timeout at all now.

When they try to set it to 300 it times out at 100

The timeout should be set as 300 seconds as per the following code and I believe I can confirm the timeout by printing it out to the log:

deepgram.SetHttpClientTimeout(TimeSpan.FromSeconds(ApiRequestTimeoutInSeconds));

_logger.LogInformation($"ApiRequestTimeoutInSeconds: {ApiRequestTimeoutInSeconds.ToString()}");

And the output from the log file:

2023-08-30 07:32:18.818 +10:00 [INF] BinConsulting.TOPS.TOPService.AsrWorker: ApiRequestTimeoutInSeconds: 300

Error:

Error while transcribing audio files: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.
DeepgramClient deepgram =
    new DeepgramClient(
        new Credentials(
            ApiKey,
            ApiUrl,
            ApiUrlRequiresSsl));
deepgram.SetHttpClientTimeout(TimeSpan.FromSeconds(300));
transcript = await deepgram.Transcription.Prerecorded.GetTranscriptionAsync(
            new StreamSource(stream, "audio/mpeg"), 
            new PrerecordedTranscriptionOptions() 
            {
                Tier = "enhanced",
                //Model = "meeting",
                Version = "latest",
                Language = "en",
                Diarize = options.EnableSpeakerSeparation,
                NamedEntityRecognition = true,
                Numerals = true,
                Punctuate = true,
                Utterances = true,
            });

Originally posted by @DamienDeepgram in #116 (comment)

@ThindalTV this appears to be related to your last change on timeouts. Any chance you could take a look at it?

I tested by setting a 1 second timeout and a large 180mb MP3 file and the request did not timeout so it seems that something is not quite right

It is most probably a bug as the 100s timeout is the default value for the timeout. I will take a look.

I am having this same issue, SetHttpClientTimeout just doesn't take effect.

Update:
I had to hotfix the Deepgram SDK so we can continue progressing internally. The problem is that the ApiRequest object took the HttpClient in its constructor which creates a pointer to the original HttpClient (see BaseClient constructor). When the SetTimeOut method in HttpClientUtil calls Create() again it creates a new HttpClient in a new location in memory. But the ApiRequest methods will all continue using the pointer to the original HttpClient it received in its ctor. I've no history on the other ticket but for the moment deleting the call to Create() in SetTimeOut would mean it updates the HttClient used by the ApiRequest object.

The team discussed this and in our next major release of the .NET SDK this issue will be addressed.

@andyr700

...for the moment deleting the call to Create() in SetTimeOut would mean it updates the HttClient used by the ApiRequest object.

Thank you! This helped me fix this bug for now, see this pull request #179 and this branch in my fork.

This PR #207 has been merged and released 3.4.1.