How to get IPv4 on apache httpclient? (Java)

My program always gets stuck for 30 seconds on

[DEBUG] SingleClientConnManager - Get connection for route HttpRoute[{}->http://foobar.com] 

Further research suggests that this is due to ipv4 failure. Is there a way to get ipv4 on httpclient to solve the problem?

PS I think this is an IPv4 problem because curl -L04 http://foobar.com is an instant download, and curl -L06 http://foobar.com produces curl: (6) Couldn't resolve host 'foobar.com'

+4
source share
1 answer

When starting your program, use:

java -Djava.net.preferIPv4Stack = true

+5
source

Source: https://habr.com/ru/post/1402547/


All Articles