Skip to content

Conversation

@marktech0813
Copy link

I added a global OkHttpClient with long timeouts and initialized AndroidNetworking with it.
I replaced per-request new OkHttpClient() usages with the shared client to avoid overriding the longer timeouts.
I aligned the Rx sample apps to initialize with the same client.

Updated app/src/main/java/com/networking/MyApplication.java to build an OkHttpClient with 120s connect/read/write timeouts and pass it to AndroidNetworking.initialize(...). Exposed getOkHttpClient() to reuse.

Updated per-request overrides in app:

  • app/src/main/java/com/networking/ApiTestActivity.java (2 spots) to use MyApplication.getInstance().getOkHttpClient().
  • app/src/main/java/com/networking/OkHttpResponseTestActivity.java (2 spots) to use the same shared client.
    Updated Rx sample apps to use the same approach:
  • rxsampleapp/src/main/java/com/rxsampleapp/RxMyApplication.java
  • rx2sampleapp/src/main/java/com/rx2sampleapp/Rx2MyApplication.java

Contribution by Gittensor, learn more at https://gittensor.io/

This ensures slow server responses (50–60s) won’t trigger premature onError due to client-side timeouts.

Updated app/src/main/java/com/networking/MyApplication.java to build an OkHttpClient with 120s connect/read/write timeouts and pass it to AndroidNetworking.initialize(...). Exposed getOkHttpClient() to reuse.

Contribution by Gittensor, learn more at https://gittensor.io/
Updated per-request overrides in app:
app/src/main/java/com/networking/ApiTestActivity.java (2 spots) to use MyApplication.getInstance().getOkHttpClient().

Contribution by Gittensor, learn more at https://gittensor.io/
app/src/main/java/com/networking/OkHttpResponseTestActivity.java (2 spots) to use the same shared client.

Contribution by Gittensor, learn more at https://gittensor.io/
Updated Rx sample apps to use the same approach:
rxsampleapp/src/main/java/com/rxsampleapp/RxMyApplication.java
rx2sampleapp/src/main/java/com/rx2sampleapp/Rx2MyApplication.java

Contribution by Gittensor, learn more at https://gittensor.io/
Updated Rx sample apps to use the same approach:
rxsampleapp/src/main/java/com/rxsampleapp/RxMyApplication.java
rx2sampleapp/src/main/java/com/rx2sampleapp/Rx2MyApplication.java

Contribution by Gittensor, learn more at https://gittensor.io/
@marktech0813
Copy link
Author

Please check PR.
Thanks.

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

Successfully merging this pull request may close these issues.

1 participant