Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.58k stars 591 forks source link

How to set read timeout duration #518

Closed RTException closed 4 months ago

RTException commented 4 months ago

Hi, In version 3.13.6, I could use Config#socketTimeout(int inMillies) to set the read timeout for responses. However, in the latest version, this method has been removed. What other ways can I use to set the timeout for both sending and receiving data, in order to control the maximum waiting time for synchronous calls?

RTException commented 4 months ago

On the Unirest-Java Documentation page, the following code can still be found:

code-socket-timeout

ryber commented 4 months ago

The setting does not exist in 4 because the Java client does not support it. I have just removed it from the documentation,

ryber commented 4 months ago

FYI there is a discussion about adding this to java: https://bugs.openjdk.org/browse/JDK-8258397

RTException commented 4 months ago

Thank you. You are right. I have checked the JDK source code and found that java.net.http.HttpClient no longer supports the socketTimeout method. I hope it will be supported in the subsequent versions of JDK because this setting is still very useful in some cases.