Fast-Android-Networking icon indicating copy to clipboard operation
Fast-Android-Networking copied to clipboard

Fix : Slow server response. #616

Open marktech0813 opened this issue 1 month ago β€’ 1 comments

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.

marktech0813 avatar Nov 12 '25 00:11 marktech0813

Please check PR. Thanks.

marktech0813 avatar Nov 12 '25 10:11 marktech0813