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

Way to add request timeout in apollo kotlin multiplatform #2680

Closed
ganesh-4212 opened this issue Oct 21, 2020 · 6 comments · Fixed by #2690
Closed

Way to add request timeout in apollo kotlin multiplatform #2680

ganesh-4212 opened this issue Oct 21, 2020 · 6 comments · Fixed by #2690

Comments

@ganesh-4212
Copy link

ganesh-4212 commented Oct 21, 2020

We don't have a way to set request timeout in Apollo client
I'm using apollo kotlin multiplatform in my project and it's amazing but i have found that there is no way to set request timeout. Both OkHttp and NSURLConnection supports it currently we have to re-implement the whole NetworkTransport in both android and ios to achieve this.

Adding requestTimeout parameter ApolloHttpNetworkTransport class
Adding the requestTimeout parameter would be a good idea.

val apolloClient = ApolloClient(
      networkTransport = ApolloHttpNetworkTransport(
          serverUrl = "https://api.example.com",
          requestTimeout = 10_000 //10 seconds
       )
 )
@martinbonnin
Copy link
Contributor

Thanks for opening that up! Do you feel like opening a PR about this? If not, I can look at the same time as #2665.

@ganesh-4212
Copy link
Author

Hi @martinbonnin thanks for the quick response. sadly i'll not be able to work on it now.

@ganesh-4212
Copy link
Author

I think you can take this along with #2665.

@andrey-nakin
Copy link

@martinbonnin What is a correct way to set a read timeout in Apollo 3.7? I no longer see ApolloHttpNetworkTransport in distribution. I would appreciate a Java example.

@martinbonnin
Copy link
Contributor

martinbonnin commented Nov 17, 2022

@andrey-nakin you can use DefaultHttpEngine:

    apolloClient = ApolloClient.Builder()
        .serverUrl("https://...")
        .httpEngine(DefaultHttpEngine(timeoutMillis = 10_000))
        .build()

@andrey-nakin
Copy link

@martinbonnin it works, thank you.

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

Successfully merging a pull request may close this issue.

3 participants