今天在使用Java jsoup操作remote server的是否,在本地执行可以成功返回内容,然后打成jar包,使用shell在 server上执行就反问错误。
java.net.SocketException: Unexpected end of file from server
sun.net.(HttpClient.java:772)
sun.net.(HttpClient.java:633)
sun.net.(HttpClient.java:769)
sun.net.(HttpClient.java:633)
sun.net.(HttpURLConnection.java:1323)
java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:516)
org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:493)
org.jsoup.helper.HttpConnection.execute(HttpConnection.java:205)
org.jsoup.helper.HttpConnection.get(HttpConnection.java:194)
在stackoverflow 上面找到同样的问题,原因是remote server 接收request,并立马关闭了request,而没有返回response;具体原因得看 trace packets,so,得安装wireshark
sudo apt-get install wireshark
但是没有那么顺利,不然就不会有这边文章了。
因为执行上面的命令之后,发现如下错误:
404 Not Found [IP: 137.189.4.14 80]
sudo apt-get update 也没有办法解决,
然后baidu了一下,发现了这边blog有办法。发现是因为Ubuntu13.10 这个版本的源有变化导致的。
更新为14.04可以解决,但是这可是正在运行的服务器,不敢冒着险。不过也可以更新源。
mv /etc/apt/sources.list /etc/apt/sources.list_20150807
touch /etc/apt/sources.list
vi /etc/apt/sources.list
然后copy一下内容
deb raring main universe restricted multiverse
deb-src raring main universe restricted multiverse
deb raring-security main universe restricted multiverse
deb-src raring-security main universe restricted multiverse
deb raring-updates main universe restricted multiverse
deb-src raring-updates main universe restricted multiverse
deb raring-backports main restricted universe multiverse
deb-src raring-backports main restricted universe multiverse
deb raring-proposed main restricted universe multiverse
deb-src raring-proposed main restricted universe multiverse
然后保存退出。
sudo apt-get update
sudo apt-get install wireshark
done.
网络抓包工具Wireshark的简单使用
Ubuntu 12.04 下安装Wireshark