I was trying to make HTTP calls using Finagle today and all I would get was
this traceback from my logs:
12345678910111213
FAT [20121215-15:49:46.803] HttpServer: A server service client threw an exception
FAT [20121215-15:49:46.803] HttpServer: com.twitter.finagle.WriteException$$anon$1: java.net.ConnectException: connection timed out
FAT [20121215-15:49:46.803] HttpServer: at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:391)
FAT [20121215-15:49:46.803] HttpServer: at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:289)
FAT [20121215-15:49:46.803] HttpServer: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
FAT [20121215-15:49:46.803] HttpServer: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
FAT [20121215-15:49:46.803] HttpServer: at java.lang.Thread.run(Thread.java:722)
FAT [20121215-15:49:46.803] HttpServer: Caused by java.net.ConnectException: connection timed out
FAT [20121215-15:49:46.803] HttpServer: at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processConnectTimeout(NioClientSocketPipelineSink.java:391)
FAT [20121215-15:49:46.803] HttpServer: at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:289)
FAT [20121215-15:49:46.803] HttpServer: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
FAT [20121215-15:49:46.803] HttpServer: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
FAT [20121215-15:49:46.803] HttpServer: at java.lang.Thread.run(Thread.java:722)
It turns out I needed to set up my ClientBuilder a little differently:
The important bits, that don’t appear well documented are tcpConnectTimeout
and requestTimeout. The normal ‘timeout’ usually used on the ClientBuilder is
not what you want.
This was more a note for me - but figured people Googling might find it useful
also.