2

I Want to know what is the recommended value for methods setConnectionTimeou() and setReadTimeOut() for HttpURL connection? I know these value depends upon the server and what task server is performing. but still i want to know the recommended values for these method.

user3586231
  • 391
  • 4
  • 21

2 Answers2

1

It's hard to answer such question without knowing the typical response time. Users are fairly accustomed to wait a few seconds when using mobile devices whilst on mobile networks.

Personally if the timeout is between 10 - 15s I will consider it a normal latency, if it is 20s or more, I will most likely quit the app.

From Default Documentation

Both setConnectTimeout (int timeout) and setReadTimeout (int timeout) From API 1

A SocketTimeoutException is thrown if the connection could not be established in this time. Default is 0 which stands for an infinite timeout.

see this link its give you more idea about this.

https://www.nngroup.com/articles/website-response-times/

Vishal Thakkar
  • 2,117
  • 2
  • 16
  • 33
1

You can do it this example: Your method How to add parameters to HttpURLConnection using POST

OR

You can follow this other form https://developer.android.com/reference/java/net/HttpURLConnection.html

Community
  • 1
  • 1
mrjusepelo
  • 51
  • 3