Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModernHttpClient , The network connection was lost, error #204

Closed
jorgenstorlie opened this issue Feb 26, 2016 · 3 comments
Closed

ModernHttpClient , The network connection was lost, error #204

jorgenstorlie opened this issue Feb 26, 2016 · 3 comments

Comments

@jorgenstorlie
Copy link

I got this error after the app is put on and off flight mode:
: System.Net.WebException: The network connection was lost. --->

Steps to reproduce:

  1. Turn on flight mode
  2. Turn off flight mode
  3. Try to get some data

The error also happen after the app is restored from background, if i has been inactive.

I use ModernHttpClient like this:

var handler = new NativeMessageHandler ();
var client = new HttpClient (handler);
System.Net.Http.HttpResponseMessage responseMsg = await client.GetAsync (url);
responseMsg.EnsureSuccessStatusCode ();
responseBody = responseMsg.Content.ReadAsStringAsync ();
returnvalue = responseBody.Result;

Do someone have the same problem?
Any solution?

Jørgen

@jorgenstorlie
Copy link
Author

Some more info:

It may be a bug in IOS:

http://stackoverflow.com/questions/25372318/error-domain-nsurlerrordomain-code-1005-the-network-connection-was-lost

http://www.pluchon.com/forum/viewtopic.php?id=36

workaround;

Increase the timeout parameter of the server above 30 seconds. It looks like iOS is always behaving as if the server will keep the connection open for 30 seconds regardless of the value provided in the Keep-Alive header. (This can be done for Apache by setting the KeepAliveTimeout option.
2)
You can simply disable the keep alive mechanism for iOS clients based on the User-Agent of your app (e.g. for Apache: BrowserMatch "iOS 8." nokeepalive in the mod file setenvif.conf)

I have not changed the server, it would be best to fix the client.

Someone having the same problem?

@jorgenstorlie
Copy link
Author

it was a problem with the server

@bengibagci
Copy link

@jorgenstorlie hi, I have the same problem. I couldn't solve this problem with Keep-Alive header. How did you solve this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants