In my application, I'm trying to connect to RabbitMQ broker as a consumer (via RabbitMQ Java Client). And in most cases connection succeed. But sometimes it fails, and I get these exceptions: java.io.IOException, java.io.EOFException. Why this error appears?
Also, when app connecting to broker as a consumer, this connection
appears in RabbitMQ manager. After some time this connection dissapears.
But client "thinks" that is still connected. Function
AMQConnection.isOpen, returns true. I think this may be related to this
exceptions, I mentioned earlier.
Acctually exceptions are not that big problem. Problem starts when client have not acctual information about connection.
Connecting to RabbitMQ:
mqConnFactory = new ConnectionFactory();
String uri = "<url to RabbitMQ>";
mqConnFactory.setExceptionHandler(exceptionHandler);
mqConnFactory.setRequestedHeartbeat(120);
mqConnFactory.setConnectionTimeout(30000);
mqConnection = (AMQConnection) mqConnFactory.newConnection();
=INFO REPORT==== 18-Feb-2016::18:02:50 ===When client calls isOpen, it returns true. It's strange. I had this error about missed heartbeats already. And to fix it, I was changing heartbeat value. I fially set heartbeat to 120s.
accepting AMQP connection <0.8913.0> (192.168.0.20:36208 -> 192.168.0.13:5672)
=ERROR REPORT==== 18-Feb-2016::18:08:50 ===
closing AMQP connection <0.8913.0> (192.168.0.20:36208 -> 192.168.0.13:5672):
missed heartbeats from client, timeout: 120s
=INFO REPORT==== 18-Feb-2016::21:56:42 ===
accepting AMQP connection <0.25224.3> (192.168.0.20:54013 -> 192.168.0.13:5672)
=ERROR REPORT==== 18-Feb-2016::22:02:42 ===
closing AMQP connection <0.25224.3> (192.168.0.20:54013 -> 192.168.0.13:5672):
missed heartbeats from client, timeout: 120s
=INFO REPORT==== 18-Feb-2016::22:03:46 ===
accepting AMQP connection <0.28703.3> (192.168.0.20:57415 -> 192.168.0.13:5672)
=ERROR REPORT==== 18-Feb-2016::22:09:46 ===
closing AMQP connection <0.28703.3> (192.168.0.20:57415 -> 192.168.0.13:5672):
missed heartbeats from client, timeout: 120s
=INFO REPORT==== 18-Feb-2016::22:13:57 ===
accepting AMQP connection <0.932.4> (192.168.0.20:58957 -> 192.168.0.13:5672)
=ERROR REPORT==== 18-Feb-2016::22:19:57 ===
closing AMQP connection <0.932.4> (192.168.0.20:58957 -> 192.168.0.13:5672):
missed heartbeats from client, timeout: 120s
=INFO REPORT==== 18-Feb-2016::22:27:09 ===
accepting AMQP connection <0.7423.4> (192.168.0.20:50481 -> 192.168.0.13:5672)
=WARNING REPORT==== 18-Feb-2016::22:29:29 ===
closing AMQP connection <0.7423.4> (192.168.0.20:50481 -> 192.168.0.13:5672):
client unexpectedly closed TCP connection
=INFO REPORT==== 18-Feb-2016::22:33:36 ===
accepting AMQP connection <0.10508.4> (192.168.0.20:35190 -> 192.168.0.13:5672)
=ERROR REPORT==== 18-Feb-2016::22:33:36 ===
closing AMQP connection <0.10508.4> (192.168.0.20:35190 -> 192.168.0.13:5672):
{handshake_timeout,handshake}
=INFO REPORT==== 18-Feb-2016::22:34:19 ===
accepting AMQP connection <0.10950.4> (192.168.0.20:41237 -> 192.168.0.13:5672)
=ERROR REPORT==== 18-Feb-2016::22:40:19 ===
closing AMQP connection <0.10950.4> (192.168.0.20:41237 -> 192.168.0.13:5672):
missed heartbeats from client, timeout: 120s
Except that logs I already pasted, these logs also appeared:
=INFO REPORT==== 18-Feb-2016::21:56:42 ===
accepting AMQP connection <0.25224.3> (192.168.0.20:54013 -> 192.168.0.13:5672)
=ERROR REPORT==== 18-Feb-2016::22:02:42 ===
closing AMQP connection <0.25224.3> (192.168.0.20:54013 -> 192.168.0.13:5672):
missed heartbeats from client, timeout: 120s
=INFO REPORT==== 18-Feb-2016::22:03:46 ===
accepting AMQP connection <0.28703.3> (192.168.0.20:57415 -> 192.168.0.13:5672)
=ERROR REPORT==== 18-Feb-2016::22:09:46 ===
closing AMQP connection <0.28703.3> (192.168.0.20:57415 -> 192.168.0.13:5672):
missed heartbeats from client, timeout: 120s
=INFO REPORT==== 18-Feb-2016::22:13:57 ===
accepting AMQP connection <0.932.4> (192.168.0.20:58957 -> 192.168.0.13:5672)
=ERROR REPORT==== 18-Feb-2016::22:19:57 ===
closing AMQP connection <0.932.4> (192.168.0.20:58957 -> 192.168.0.13:5672):
missed heartbeats from client, timeout: 120s
=INFO REPORT==== 18-Feb-2016::22:27:09 ===
accepting AMQP connection <0.7423.4> (192.168.0.20:50481 -> 192.168.0.13:5672)
=WARNING REPORT==== 18-Feb-2016::22:29:29 ===
closing AMQP connection <0.7423.4> (192.168.0.20:50481 -> 192.168.0.13:5672):
client unexpectedly closed TCP connection
=INFO REPORT==== 18-Feb-2016::22:33:36 ===
accepting AMQP connection <0.10508.4> (192.168.0.20:35190 -> 192.168.0.13:5672)
=ERROR REPORT==== 18-Feb-2016::22:33:36 ===
closing AMQP connection <0.10508.4> (192.168.0.20:35190 -> 192.168.0.13:5672):
{handshake_timeout,handshake}
=INFO REPORT==== 18-Feb-2016::22:34:19 ===
accepting AMQP connection <0.10950.4> (192.168.0.20:41237 -> 192.168.0.13:5672)
=ERROR REPORT==== 18-Feb-2016::22:40:19 ===
closing AMQP connection <0.10950.4> (192.168.0.20:41237 -> 192.168.0.13:5672):
missed heartbeats from client, timeout: 120sWhen client disconnects, I expect to handleShutdownSignal is called. And sometimes it is. But not always. And thats the problem.
=INFO REPORT==== 20-Feb-2016::13:45:13 ===
accepting AMQP connection <0.13061.19> (192.168.0.20:45018 -> 192.168.0.13:5672)
=ERROR REPORT==== 20-Feb-2016::13:48:14 ===
closing AMQP connection <0.13061.19> (192.168.0.20:45018 -> 192.168.0.13:5672):
missed heartbeats from client, timeout: 10s
=INFO REPORT==== 20-Feb-2016::13:48:16 ===
accepting AMQP connection <0.14574.19> (192.168.0.20:59819 -> 192.168.0.13:5672)
=ERROR REPORT==== 20-Feb-2016::13:49:06 ===
closing AMQP connection <0.14574.19> (192.168.0.20:59819 -> 192.168.0.13:5672):
missed heartbeats from client, timeout: 10s
=INFO REPORT==== 20-Feb-2016::13:49:10 ===
accepting AMQP connection <0.15021.19> (192.168.0.20:41576 -> 192.168.0.13:5672)
=ERROR REPORT==== 20-Feb-2016::13:49:40 ===
closing AMQP connection <0.15021.19> (192.168.0.20:41576 -> 192.168.0.13:5672):
missed heartbeats from client, timeout: 10s
I believe http://rabbitmq.com/heartbeats.html explains why. 120 seconds is a pretty high heartbeat interval,perhaps you want something more like 10 seconds.