none
How to set inactivityTimeout at a WPFApplication client request RRS feed

  • Question

  • Hi,

    We are working in a WPF Application that calls (HttpClient) some of our WebAPIs. One of the POST requests is a long running task that can take longer than 15 minutes.

    Although we have set HttpClient.Timeout property to 30 minutes, we are experiencing some disconnects after 10 minutes.

    I imagine this due to some idle connection timeout our customers may have set on their internal proxy servers.

    In order to overcome this issue, we are thinking about setting a "inactivity timeout" on the connection properties. It seems there is a ReliableSession.InactivityTimeout property available, but not for HttpClient class.

    Do you have any ideas how can I use this (or a similar) mechanism on my wpf client app?

    Thank you,

    Igor. 


    .NET Software developer for industrial internet and automation system.

    Wednesday, January 28, 2015 9:51 AM

Answers

All replies

  • Web applications and services tend to and are meant to be stateless and running long requests like this (15 minutes!) is like asking for trouble. Trying to keep the same request alive for 15 minutes doesn't make much sense and will probably not work very well either if the distance between the client and server is not very short. There will always be some network latency.

    There are a number of ways you can address issues like this. You could for example send a (short-lived) request from the client to server and then send another request from the server to the client (by setting up a service on the client side for example) once the server has finished processing the request sent by the client. Or the client app can check back occasionally to see if the process has completed.

    A more solid approach to this kind of issues is to use some kind of message queue. You submit messages into a queue, and have another application pick up the incoming request to process. This is a topic way to big to discuss here though. Please refer to the following page for more information: http://www.codemag.com/Article/0102091

    Please remember to mark helpful posts as answer and/or helpful.

    Wednesday, January 28, 2015 11:47 AM
  • Hello Magnus,

    Thank you for the advice. We know about the problems we might face with such long running process.

    I am not looking (for now) a solid approach. The motivation at this moment is to overcome an eventual proxy idle disconnect from our customer network.

    Is there a ReliableSession.InactivityTimeout or something similar supported by .NET 4.5 that can be used?

    Thank you,

    Igor.


    .NET Software developer for industrial internet and automation system.

    Wednesday, January 28, 2015 1:44 PM
  • >>Is there a ReliableSession.InactivityTimeout or something similar supported by .NET 4.5 that can be used?

    Not apart from this one: https://msdn.microsoft.com/en-us/library/system.servicemodel.reliablesession.inactivitytimeout(v=vs.110).aspx

    The HttpClient class only has the Timeout property.

    You could possibly try to use the asynchronous versions of the HttpWebRequest class' GetRequestStream and GetResponse method: http://www.thomaslevesque.com/2014/01/14/tackling-timeout-issues-when-uploading-large-files-with-httpwebrequest/

    Please remember to mark helpful posts as answer and/or helpful.

    Wednesday, January 28, 2015 2:42 PM