Sometimes HttpURLConnection.getInputStream executes too slowly

前端 未结 6 1318
情深已故
情深已故 2020-12-09 12:56

We have next code.
Sometimes we should wait 10-20-40 seconds on the last line.
What can be the problem?

Java 1.4

URL url = ...;
HttpURLConn         


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 13:14

    Had the same problem, found out it was caused by IPv6.

    You Disable it from code using:

    System.setProperty("java.net.preferIPv4Stack" , "true");
    

    You can also disable it via the command line using : g-Djava.net.preferIPv4Stack=true

提交回复
热议问题