New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected java.net.SocketTimeoutException from URL "http://www.dilbert.com" #26

Closed
kypeli opened this Issue Jul 21, 2013 · 4 comments

Comments

Projects
None yet
3 participants
@kypeli

kypeli commented Jul 21, 2013

It seems I can make GET requests successfully to a given site - except to "http://www.dilbert.com". Then I get a java.net.SocketTimeoutException, although the site seems to be responding to HTTP requests normally.

Please see below:

Welcome to Scala version 2.10.0 (Java HotSpot(TM) Client VM, Java 1.7.0_17).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import scalaj.http.Http
import scalaj.http.Http

scala> val html = Http("http://www.dilbert.com").asString
java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:378)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:473)

But the site is up:

kypeli@iceberg:~$ curl -I http://www.dilbert.com
HTTP/1.1 200 OK
Date: Sun, 21 Jul 2013 09:26:08 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.2.10
Set-Cookie: PHPSESSID=3oeodcel2pacdgd7cpoel95vo5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=5nvtfb4m3qsm1hiknsglo6lmq4; path=/
Set-Cookie: PHPSESSID=69t1p2kc5afs3de3gi75ouuoq2; path=/
Set-Cookie: PHPSESSID=tbfjgtkn6dk6mgogtdv6evl0p1; path=/
Set-Cookie: PHPSESSID=5punq0q7rsm8b9q4357l2lb8a1; path=/
Connection: close
Content-Type: text/html; charset=utf-8lias

And I can make requests to other sites:

scala> val html = Http("http://www.google.com").asString
html: String =
<!doctype html><title>Google</title><script>(function(){
window.google={kEI:"TKnrUYe4I-zZ0QXx7IGIDg",getEI:function(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||google.kEI},https:function(){return"https:"==window.location.

@kypeli

This comment has been minimized.

Show comment
Hide comment
@kypeli

kypeli Jul 21, 2013

Ok - I don't know what's going on, but as of writing this, it seems dilbert.com is working. But I get similar errors from other sites:

scala> val html = Http("http://www.sinfest.net").asString
java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)

scala> val html = Http("http://nyt.fi/category/sarjakuvat/").asString
java.net.SocketTimeoutException: Read timed out
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1674)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1672)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1670)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1243)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at scalaj.http.Http$Request.process(Http.scala:125)

Both URLs above work ok with "curl -I".

Am I using the library wrong, or what could be going on?

kypeli commented Jul 21, 2013

Ok - I don't know what's going on, but as of writing this, it seems dilbert.com is working. But I get similar errors from other sites:

scala> val html = Http("http://www.sinfest.net").asString
java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)

scala> val html = Http("http://nyt.fi/category/sarjakuvat/").asString
java.net.SocketTimeoutException: Read timed out
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1674)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1672)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1670)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1243)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at scalaj.http.Http$Request.process(Http.scala:125)

Both URLs above work ok with "curl -I".

Am I using the library wrong, or what could be going on?

@xuwei-k

This comment has been minimized.

Show comment
Hide comment
@kypeli

This comment has been minimized.

Show comment
Hide comment
@kypeli

kypeli Jul 21, 2013

Thanks for pointing me to these! To me the defaults look a bit too low for "real life" network conditions, no? I would expect timeouts to be in the order of seconds...

kypeli commented Jul 21, 2013

Thanks for pointing me to these! To me the defaults look a bit too low for "real life" network conditions, no? I would expect timeouts to be in the order of seconds...

@hoffrocket

This comment has been minimized.

Show comment
Hide comment
@hoffrocket

hoffrocket Jul 21, 2013

Member

"real life" depends greatly on your use case. The library's first use was within a web application where longer timeouts would cause undesirable latencies for end users.

Member

hoffrocket commented Jul 21, 2013

"real life" depends greatly on your use case. The library's first use was within a web application where longer timeouts would cause undesirable latencies for end users.

@hoffrocket hoffrocket closed this Jul 21, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment