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

Timeout value is not respected on Android #192

Open
thefex opened this issue Nov 9, 2015 · 10 comments
Open

Timeout value is not respected on Android #192

thefex opened this issue Nov 9, 2015 · 10 comments

Comments

@thefex
Copy link

thefex commented Nov 9, 2015

Request never timeouts on Android (when there is established connection and timeout is due to external server responding slow , socket-like timeout).
Reason:
OkHttpClient.SetConnectionTimeout, ReadTimeout, WriteTimeout is not used, default value of 0 means: NO TIMEOUT.

Working on fix.

@thefex
Copy link
Author

thefex commented Nov 9, 2015

Fixed
Making pull request ( I updated ilbs to v2.5 too )
Please take care of iOS separetely.

fabionuno added a commit to fabionuno/ModernHttpClient that referenced this issue Nov 20, 2015
 Timeout value is not respected on Android anaisbetts#192
@adammeaney
Copy link

I found with my own project that changing the OkHttpNetworkHandler to set the timeouts for the OkHttpClient to 0 (which signifies infinite), then checking the IOException for if the task was cancelled seems to be a cleaner approach.

This lets the HttpClientHandler use the cancellation token, which gets cancelled on the C# HttpClient after the timeout finishes.

Less hassle, no extra properties, works fairly well.

@alexrainman
Copy link

I am having this issue right now. I have an endpoint that takes a while so i set a 30 seconds timeout but the call timeouts before the 30 seconds, any idea?

@ghost
Copy link

ghost commented May 26, 2016

@thefex is it possible for you to update the PR to the latest OKHttp (if it isn't already).

@paulcbetts needs to give some love to this repo. it's been neglected!

@thefex
Copy link
Author

thefex commented May 26, 2016

@robertbaker I don't use ModernHttpClient anymore. I use new Xamarin HTTP stack implementation.

@lhaussknecht
Copy link

@thefex Is the Xamarin HTTP stack available in Android projects?

@thefex
Copy link
Author

thefex commented Jun 29, 2016

@lhaussknecht Sure it is. As opposed to the iOS projects it is not available in GUI settings. I have asked Miguel de Icaza about that - he said GUI option will be available in future (in next releases) as Android team hit release deadline. You can set it manually in code:
var client = new HttpClient (
new Xamarin.Android.Net.AndroidClientHandler ());

or using @(AndroidEnvironment) build action:
XA_HTTP_CLIENT_HANDLER_TYPE=Xamarin.Android.Net.AndroidClientHandler

@rubit0
Copy link

rubit0 commented Jan 22, 2017

I am having kinda the same issue, timeout settings above 49 milliseconds will be ignored and the HttpClient will use the default timeout. Though, no problems on iOS.

@zeezment
Copy link

zeezment commented Dec 6, 2017

Hi, I'm having the same issue. I'm trying to check for server availability and I set the timeout property on the HttpClient to 2 seconds but it takes over a minute to timeout. Is there a fix for this?

@alexrainman
Copy link

I released a new version of the plugin that fix this issue. I am planning to do more. Search for modernhttpclient-updated.

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

6 participants