[rabbitmq-discuss] Long timeout if server host becomes unreachable

Michael Klishin michael at rabbitmq.com
Mon Oct 7 14:37:03 BST 2013


On oct 7, 2013, at 4:26 p.m., Oleg Lyalikov <oleg.lyalikov at gmail.com> wrote:

> "main" prio=10 tid=0xf7505800 nid=0x2c3e runnable [0xf7728000]
>   java.lang.Thread.State: RUNNABLE
>        at java.net.SocketOutputStream.socketWrite0(Native Method)
>        at
> java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
>        at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
>        at
> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
>        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
>        - locked <0xb4532608> (a java.io.BufferedOutputStream)
>        at java.io.DataOutputStream.flush(DataOutputStream.java:123)
>        at
> com.rabbitmq.client.impl.SocketFrameHandler.flush(SocketFrameHandler.java:142)
>        at
> com.rabbitmq.client.impl.AMQConnection.flush(AMQConnection.java:488)
>        at com.rabbitmq.client.impl.AMQCommand.transmit(AMQCommand.java:125)
>        at
> com.rabbitmq.client.impl.AMQChannel.quiescingTransmit(AMQChannel.java:316)
>        - locked <0xb4532ee8> (a java.lang.Object)
>        at com.rabbitmq.client.impl.AMQChannel.transmit(AMQChannel.java:292)
>        - locked <0xb4532ee8> (a java.lang.Object)
>        at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:634)
>        at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:617)
>        at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:608)

If SocketOutputStream#socketWrite0 takes minutes to timeout, it may be
worth trying setting SO_LINGER on the socket (SO_TIMEOUT sounds like
what you want but I believe it only covers read operations):

http://docs.oracle.com/javase/7/docs/api/java/net/Socket.html#setSoLinger(boolean,%20int)

To do so, for example, you can subclass default ConnectionFactory and override
#configureSocket:

http://hg.rabbitmq.com/rabbitmq-java-client/file/46578678645e/src/com/rabbitmq/client/ConnectionFactory.java#l476

Note that SO_LINGER is not free of downsides:

http://blog.netherlabs.nl/articles/2009/01/18/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable
http://stackoverflow.com/questions/3757289/tcp-option-so-linger-zero-when-its-required

You can try reducing maximum packet age for the server, this should reduce the amount of
time spent in TIME_WAIT.

MK



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20131007/bbe24e4b/attachment.pgp>


More information about the rabbitmq-discuss mailing list