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 #24

Closed
willemevenwel opened this issue Sep 9, 2016 · 3 comments
Closed

TimeOut #24

willemevenwel opened this issue Sep 9, 2016 · 3 comments

Comments

@willemevenwel
Copy link

How can I change the time out on a service request?

Something like:

AndroidNetworking.post(pUrl)
.addByteBody(bytes)
.setContentType("application/json")
.setPriority(Priority.HIGH)
.setExecutor(Executors.newSingleThreadExecutor())
.setTimeOut(60000) //milis
.build()
.getAsOkHttpResponse(new OkHttpResponseListener() {

@amitshekhariitbhu
Copy link
Owner

amitshekhariitbhu commented Sep 9, 2016

OkHttpClient okHttpClient = new OkHttpClient().newBuilder()
                .connectTimeout(60, TimeUnit.SECONDS)
                .readTimeout(60, TimeUnit.SECONDS)
                . writeTimeout(60, TimeUnit.SECONDS)
                .build();

AndroidNetworking.get("https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}")
                 .addPathParameter("pageNumber", "0")
                 .addQueryParameter("limit", "3")
                 .setOkHttpClient(okHttpClient) // passing a custom okHttpClient 
                 .build()
                 .getAsJSONArray(new JSONArrayRequestListener() {
                    @Override
                    public void onResponse(JSONArray response) {
                      // do anything with response
                    }
                    @Override
                    public void onError(ANError error) {
                    // handle error
                    }
                });

@willemevenwel
Copy link
Author

Fantastic thanks.

On Fri, Sep 9, 2016 at 3:39 PM, AMIT SHEKHAR notifications@github.com
wrote:

You can set your custom okhttp client with custom timeout with
setokhttpclient method


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#24 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ANFe3oERN8_nFmAV24XV89-3cNEMC7zRks5qoWGZgaJpZM4J5DR-
.

@amitshekhariitbhu
Copy link
Owner

You are welcome

Thanks
Amit Shekhar

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