Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

HttpClient Timeout not working in some cases

$
0
0

My app uses HttpClient to pull data from a server. I have set Timeout = 8 sec. In most cases when there's a problem communicating with the server, the 8 sec timeout is honored. However, in some cases it's taking 90 sec to timeout the connection. This is way too long for our needs. One case where I've experienced this is when the request results in this exception:

2015-01-29 10:18:44.446 skillstore[958:185556]  8 DEBUG Skillstore.AppLogic.Rest.Request: ExecuteAsync - starting POST http://192.168.1.192:9000/api/v1/auth/token
2015-01-29 10:19:59.742 skillstore[958:185552]  7 ERROR Skillstore.AppLogic.Rest.Request: ExecuteAsync - WebException from POST http://192.168.1.192:9000/api/v1/auth/token, retry count = 1: System.Net.WebException: Error: ConnectFailure (Connection timed out) ---> System.Net.Sockets.SocketException: Connection timed out
  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x000f1] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.6.0.51/src/mono/mcs/class/System/System.Net.Sockets/Socket_2_1.cs:1257 
  at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x001c2] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.6.0.51/src/mono/mcs/class/System/System.Net/WebConnection.cs:213 

Is there some socket level timeout param I need to set? I'm considering as a workaround starting a separate task to monitor the request and cancel it if it exceeds 8 sec, but that seems like a real hack.

Thanks,
David


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>