Customizable timeout, Customizable levels and proxy settings in UniRest
1. Customizable Timeouts
You can set custom connection and socket timeout values (in milliseconds):
Unirest.setTimeouts(long connectionTimeout, long socketTimeout);
By default the connection timeout (the time it takes to connect to a server) is 10000
, and the socket timeout (the time it takes to receive data) is 60000
. You can set any of these timeouts to zero to disable the timeout.
Unirest.setTimeouts(20000, 15000)
2. Customizable levels:
Let’s set the number of connections and number maximum connections per route:
Unirest.setConcurrency(20, 5);
By default the maxTotal (overall connection limit in the pool) is 200
, and the maxPerRoute (connection limit per target host) is 20
.
3. Proxy
You can set a proxy by invoking:
Unirest.setProxy(new HttpHost("127.0.0.1", 8000));