SimpleAmqpClient / rabbitmq-c : Network disconnect scenario - Connect returns after 64 seconds

384 views
Skip to first unread message

Kiran D

unread,
Aug 15, 2017, 7:55:20 PM8/15/17
to rabbitmq-c-users
Hi Allan,

I am testing network error recovery for our SAC clients and found the clients take ~ 70 seconds to return from a connect error when the network cable is disconnected.
I have enabled heartbeats and set the BROKER_HEARTBEAT=10 in ChannelImpl.cpp. 

Sequence of events:

1. Client connects to RabbitMQ broker using SAC::CreateSecure()
2. Connection is established and remains idle.
3. Disconnect the network connection between client host and RabbitMQ server
4. Client gets disconnected due to heartbeat timeout. This is as expected based on the heartbeat configuration. 
5. Client attempts reconnection by calling SAC::CreateSecure() again on the same RMQ host.
6. This connection attempt fails and returns only after 64 secs.

I'd prefer for the call to timeout sooner while I increase number of reconnect attempts if needed. Is the connect method configurable for timeout in rabbitmq-c? 

Regards,
Kiran

Alan Antonuk

unread,
Aug 21, 2017, 1:02:46 AM8/21/17
to Kiran D, rabbitmq-c-users
On Tue, Aug 15, 2017 at 4:55 PM Kiran D <kirand...@gmail.com> wrote:
Hi Allan,

I am testing network error recovery for our SAC clients and found the clients take ~ 70 seconds to return from a connect error when the network cable is disconnected.
I have enabled heartbeats and set the BROKER_HEARTBEAT=10 in ChannelImpl.cpp. 
Note that this is not a public API in SimpleAmqpClient, its an internal implementation detail that may change.  When making this sort of change to the underlying implementation please test carefully.  

Sequence of events:

1. Client connects to RabbitMQ broker using SAC::CreateSecure()
2. Connection is established and remains idle.
3. Disconnect the network connection between client host and RabbitMQ server
4. Client gets disconnected due to heartbeat timeout. This is as expected based on the heartbeat configuration. 
5. Client attempts reconnection by calling SAC::CreateSecure() again on the same RMQ host.
6. This connection attempt fails and returns only after 64 secs.

I'd prefer for the call to timeout sooner while I increase number of reconnect attempts if needed. Is the connect method configurable for timeout in rabbitmq-c? 

rabbitmq-c offers amqp_socket_open_noblock Which allows which allows specification of a timeout when attempting to connect to the broker, and amqp_set_handshake_timeout, Which allows specification of a timeout when attempting to login with the broker.

-Alan 
 

Regards,
Kiran

--
You received this message because you are subscribed to the Google Groups "rabbitmq-c-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-c-use...@googlegroups.com.
To post to this group, send email to rabbitmq...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rabbitmq-c-users/abf069a9-921c-406e-b9ae-c035083e67a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kiran D

unread,
Aug 21, 2017, 2:51:51 PM8/21/17
to rabbitmq-c-users
Thanks Allan. In order to utilize amqp_socket_open_noblock feature, I will have to replace amqp_socket_open in Channel.cpp with noblock variant. What about the amqp_set_handshake_timeout? Should this be set just before amqp_tcp_socket_new and amqp_socket_open_noblock in channel ctor?

Regards,
Kiran

Alan Antonuk

unread,
Aug 21, 2017, 10:50:19 PM8/21/17
to Kiran D, rabbitmq-c-users
On Mon, Aug 21, 2017 at 11:51 AM Kiran D <kirand...@gmail.com> wrote:
Thanks Allan. In order to utilize amqp_socket_open_noblock feature, I will have to replace amqp_socket_open in Channel.cpp with noblock variant. What about the amqp_set_handshake_timeout? Should this be set just before amqp_tcp_socket_new and amqp_socket_open_noblock in channel ctor?
amqp_set_handshake_timeout applies to amqp_login, it can be set any time before calling that function.

Kiran D

unread,
Aug 23, 2017, 12:03:31 AM8/23/17
to rabbitmq-c-users
Thanks Alan! That helped.
Reply all
Reply to author
Forward
0 new messages