JSOUP连接超时 java.net.SocketTimeoutException: Read timed out

IT黑名单 2017-4-17 9:22:02

java.net.SocketTimeoutException: Read timed out
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
	at java.net.SocketInputStream.read(SocketInputStream.java:170)
	at java.net.SocketInputStream.read(SocketInputStream.java:141)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
	at sun.net.www.MeteredStream.read(MeteredStream.java:134)
	at java.io.FilterInputStream.read(FilterInputStream.java:133)
	at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3335)
	at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:238)
	at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
	at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:117)
	at java.io.FilterInputStream.read(FilterInputStream.java:107)
	at org.jsoup.helper.DataUtil.readToByteBuffer(DataUtil.java:158)
	at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:618)
	at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:540)
	at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:227)
	at org.jsoup.helper.HttpConnection.get(HttpConnection.java:216)

解决方案

Document doc = Jsoup.connect("http://xxx.com/").timeout(6000).get();// timeout(ms) 毫秒

转载请注明来源【IT黑名单

本文链接:http://blog.itblacklist.cn/20170417/8448.html

© Copyright 2016 IT黑名单 Inc.All Rights Reserved. 豫ICP备15018592号-2