Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Owin Self-Hosted WebApi Timeout Settings

I got an Owin self-hosted web-api server, and I'm wondering if I need to change timeout settings when there are huge file downloads? The client I'm using reads the response withHttpCompletionOption.ResponseHeadersRead.

During debugging, after I stopped for some time in a breakpoint, I got an exception on client side while trying to read from a received stream:

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

While debugging I can reproduce this issue. It happens after around 30 seconds waiting in a breakpoint, after the Get-Request to the server returned.

Is this due to some kind of idle timeout, because I hold in a breakpoint and do not work on the received stream? Or can it also happen while I'm reading from the stream when my collection is slow and it takes too long?

like image 428
DanielG Avatar asked Oct 18 '22 22:10

DanielG


1 Answers

Very old question but may help whoever hits the same wall. I had the same problem with a streaming content and found the initial clue inside HTTPERR folder (C:\Windows\System32\LogFiles\HTTPERR)

 2016-08-12 09:17:52 ::1%0 60095 ::1%0 8000 HTTP/1.1 GET 
 /endpoint/audiostream/0/0/streamer.mp3 - - - Timer_MinBytesPerSecond -

 2016-08-12 09:18:19 ::1%0 60118 ::1%0 8000 HTTP/1.1 GET 
 /endpoint/audiostream/0/0/streamer.mp3 - - - Request_Cancelled -

Owin HttpListener has a TimeOutManager property that allows you to change most timeout/limits. The only way I found to get my webapp HttpListener instance was by accessing its properties

var listener = (OwinHttpListener);
app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener" ]);
listener.Listener.TimeoutManager.MinSendBytesPerSecond = uint.MaxValue;

According to owin codebase, uint.MaxValue as MinSendBytesPerSecond will just disable the flag.

like image 50
Gianandrea Avatar answered Oct 21 '22 16:10

Gianandrea