You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Toralf Lund <to...@pgs.com> on 2011/11/23 10:05:36 UTC

How to avoid waiting for a very long timeout on messaging::Connection::open()?

Hello,

Sometimes the host I'm connecting to via qpid::messaging::Connection 
turns out to be down. When this is the case, the open() call may exhibit 
two different kinds of behaviour, depending on the network configuration 
or something:

   1. An exception is raised almost immediately, and a message like
      2011-11-23 09:15:44 warning Connect failed: No route to host
      is logged.
   2. An exception is raised after a *long* delay, and log message is
      2011-11-23 09:25:01 warning Connect failed: Connection timed out

Now, case 1) is not really much of an issue, but 2) is rather 
problematic because the timeout is something like 4 minutes, and I don't 
want to lock up my application for that long. Questions:

   1. Why is it that I sometimes get "No route to host" and at other
      times have to wait for a timeout? Through what mechanism does the
      system (sometimes) know or find out directly that the remote host
      is missing, so that it doesn't have to wait for timeouts etc? I
      realise that this is more of a general sockets or TCP question
      than something specific to QPid or AMQP, but does anyone here know?
   2. Is there any way to make the timeout for case 2) shorter? I tried
      setting the "reconnect-timeout" option on the connection, but this
      made no difference.

Thanks,

- Toralf


This e-mail, including any attachments and response string, may contain proprietary information which is confidential and may be legally privileged. It is for the intended recipient only. If you are not the intended recipient or transmission error has misdirected this e-mail, please notify the author by return e-mail and delete this message and any attachment immediately. If you are not the intended recipient you must not use, disclose, distribute, forward, copy, print or rely on this e-mail in any way except as permitted by the author.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: How to avoid waiting for a very long timeout on messaging::Connection::open()?

Posted by Gordon Sim <gs...@redhat.com>.
On 11/23/2011 12:30 PM, Toralf Lund wrote:
> Pavel Moravec wrote:
>> Hi Toralf,
>> see Programming in Apache Qpid
>> (http://qpid.apache.org/documentation.html, direct link:
>> http://qpid.apache.org/books/0.12/Programming-In-Apache-Qpid/pdf/Programming-In-Apache-Qpid.pdf)
>> and Section 2.10. Connection Options.
> Thanks, I wasn't aware of that document - it may prove very useful.
>
> Some of the finer details regarding heartbeats are are not entirely
> clear from this, though. Like, when do they start being sent?

Once the AMQP connection handshake has completed.

> When the
> option is enabled, or not until open() is called?

They aren't actually sent until the connection is opened. However the 
client starts timing from the point it requests the open so that if the 
connection is not actually established, it will time out.

> And what exactly are
> they anyway? Surely not "normal" data across the TCP link, since they
> can also help detecting a connection problem?

They are just special AMQP controls send over TCP. They are really 
intended for detecting loss of a connection in a timely manner. However 
the c++ client also relies on them for detecting failure to connect in a 
more timely manner.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: How to avoid waiting for a very long timeout on messaging::Connection::open()?

Posted by Toralf Lund <to...@pgs.com>.
Pavel Moravec wrote:
> Hi Toralf,
> see Programming in Apache Qpid (http://qpid.apache.org/documentation.html, direct link: http://qpid.apache.org/books/0.12/Programming-In-Apache-Qpid/pdf/Programming-In-Apache-Qpid.pdf) and Section 2.10. Connection Options.
>   
Thanks, I wasn't aware of that document - it may prove very useful.

Some of the finer details regarding heartbeats are are not entirely 
clear from this, though. Like, when do they start being sent? When the 
option is enabled, or not until open() is called? And what exactly are 
they anyway? Surely not "normal" data across the TCP link, since they 
can also help detecting a connection problem?

- Toralf
> Kind regards,
> Pavel
>
>
>
> ----- Original Message -----
>   
>> From: "Toralf Lund" <to...@pgs.com>
>> To: users@qpid.apache.org
>> Sent: Wednesday, November 23, 2011 10:53:23 AM
>> Subject: Re: How to avoid waiting for a very long timeout on messaging::Connection::open()?
>>
>> Gordon Sim wrote:
>>     
>>> On 11/23/2011 09:05 AM, Toralf Lund wrote:
>>>   
>>>       
>>>> Hello,
>>>>
>>>> Sometimes the host I'm connecting to via
>>>> qpid::messaging::Connection
>>>> turns out to be down. When this is the case, the open() call may
>>>> exhibit
>>>> two different kinds of behaviour, depending on the network
>>>> configuration
>>>> or something:
>>>>
>>>> 1. An exception is raised almost immediately, and a message like
>>>> 2011-11-23 09:15:44 warning Connect failed: No route to host
>>>> is logged.
>>>> 2. An exception is raised after a *long* delay, and log message is
>>>> 2011-11-23 09:25:01 warning Connect failed: Connection timed out
>>>>
>>>> Now, case 1) is not really much of an issue, but 2) is rather
>>>> problematic because the timeout is something like 4 minutes, and I
>>>> don't
>>>> want to lock up my application for that long. Questions:
>>>>
>>>> 1. Why is it that I sometimes get "No route to host" and at other
>>>> times have to wait for a timeout? Through what mechanism does the
>>>> system (sometimes) know or find out directly that the remote host
>>>> is missing, so that it doesn't have to wait for timeouts etc? I
>>>> realise that this is more of a general sockets or TCP question
>>>> than something specific to QPid or AMQP, but does anyone here
>>>> know?
>>>> 2. Is there any way to make the timeout for case 2) shorter? I
>>>> tried
>>>> setting the "reconnect-timeout" option on the connection, but this
>>>> made no difference.
>>>>     
>>>>         
>>> Set the heartbeat option, then the connection will abort if two
>>> heartbeat intervals pass with no response from the server.
>>>   
>>>       
>> OK, thanks. This seems to help.
>>
>> Is the option documented anywhere?
>>
>> - Toralf
>>
>>
>> This e-mail, including any attachments and response string, may
>> contain proprietary information which is confidential and may be
>> legally privileged. It is for the intended recipient only. If you
>> are not the intended recipient or transmission error has misdirected
>> this e-mail, please notify the author by return e-mail and delete
>> this message and any attachment immediately. If you are not the
>> intended recipient you must not use, disclose, distribute, forward,
>> copy, print or rely on this e-mail in any way except as permitted by
>> the author.
>>
>> ---------------------------------------------------------------------
>> Apache Qpid - AMQP Messaging Implementation
>> Project:      http://qpid.apache.org
>> Use/Interact: mailto:users-subscribe@qpid.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>   


This e-mail, including any attachments and response string, may contain proprietary information which is confidential and may be legally privileged. It is for the intended recipient only. If you are not the intended recipient or transmission error has misdirected this e-mail, please notify the author by return e-mail and delete this message and any attachment immediately. If you are not the intended recipient you must not use, disclose, distribute, forward, copy, print or rely on this e-mail in any way except as permitted by the author.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: How to avoid waiting for a very long timeout on messaging::Connection::open()?

Posted by Pavel Moravec <pm...@redhat.com>.
Hi Toralf,
see Programming in Apache Qpid (http://qpid.apache.org/documentation.html, direct link: http://qpid.apache.org/books/0.12/Programming-In-Apache-Qpid/pdf/Programming-In-Apache-Qpid.pdf) and Section 2.10. Connection Options.

Kind regards,
Pavel



----- Original Message -----
> From: "Toralf Lund" <to...@pgs.com>
> To: users@qpid.apache.org
> Sent: Wednesday, November 23, 2011 10:53:23 AM
> Subject: Re: How to avoid waiting for a very long timeout on messaging::Connection::open()?
> 
> Gordon Sim wrote:
> > On 11/23/2011 09:05 AM, Toralf Lund wrote:
> >   
> >> Hello,
> >>
> >> Sometimes the host I'm connecting to via
> >> qpid::messaging::Connection
> >> turns out to be down. When this is the case, the open() call may
> >> exhibit
> >> two different kinds of behaviour, depending on the network
> >> configuration
> >> or something:
> >>
> >> 1. An exception is raised almost immediately, and a message like
> >> 2011-11-23 09:15:44 warning Connect failed: No route to host
> >> is logged.
> >> 2. An exception is raised after a *long* delay, and log message is
> >> 2011-11-23 09:25:01 warning Connect failed: Connection timed out
> >>
> >> Now, case 1) is not really much of an issue, but 2) is rather
> >> problematic because the timeout is something like 4 minutes, and I
> >> don't
> >> want to lock up my application for that long. Questions:
> >>
> >> 1. Why is it that I sometimes get "No route to host" and at other
> >> times have to wait for a timeout? Through what mechanism does the
> >> system (sometimes) know or find out directly that the remote host
> >> is missing, so that it doesn't have to wait for timeouts etc? I
> >> realise that this is more of a general sockets or TCP question
> >> than something specific to QPid or AMQP, but does anyone here
> >> know?
> >> 2. Is there any way to make the timeout for case 2) shorter? I
> >> tried
> >> setting the "reconnect-timeout" option on the connection, but this
> >> made no difference.
> >>     
> >
> > Set the heartbeat option, then the connection will abort if two
> > heartbeat intervals pass with no response from the server.
> >   
> OK, thanks. This seems to help.
> 
> Is the option documented anywhere?
> 
> - Toralf
> 
> 
> This e-mail, including any attachments and response string, may
> contain proprietary information which is confidential and may be
> legally privileged. It is for the intended recipient only. If you
> are not the intended recipient or transmission error has misdirected
> this e-mail, please notify the author by return e-mail and delete
> this message and any attachment immediately. If you are not the
> intended recipient you must not use, disclose, distribute, forward,
> copy, print or rely on this e-mail in any way except as permitted by
> the author.
> 
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
> 
> 

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: How to avoid waiting for a very long timeout on messaging::Connection::open()?

Posted by Toralf Lund <to...@pgs.com>.
Gordon Sim wrote:
> On 11/23/2011 09:05 AM, Toralf Lund wrote:
>   
>> Hello,
>>
>> Sometimes the host I'm connecting to via qpid::messaging::Connection
>> turns out to be down. When this is the case, the open() call may exhibit
>> two different kinds of behaviour, depending on the network configuration
>> or something:
>>
>> 1. An exception is raised almost immediately, and a message like
>> 2011-11-23 09:15:44 warning Connect failed: No route to host
>> is logged.
>> 2. An exception is raised after a *long* delay, and log message is
>> 2011-11-23 09:25:01 warning Connect failed: Connection timed out
>>
>> Now, case 1) is not really much of an issue, but 2) is rather
>> problematic because the timeout is something like 4 minutes, and I don't
>> want to lock up my application for that long. Questions:
>>
>> 1. Why is it that I sometimes get "No route to host" and at other
>> times have to wait for a timeout? Through what mechanism does the
>> system (sometimes) know or find out directly that the remote host
>> is missing, so that it doesn't have to wait for timeouts etc? I
>> realise that this is more of a general sockets or TCP question
>> than something specific to QPid or AMQP, but does anyone here know?
>> 2. Is there any way to make the timeout for case 2) shorter? I tried
>> setting the "reconnect-timeout" option on the connection, but this
>> made no difference.
>>     
>
> Set the heartbeat option, then the connection will abort if two 
> heartbeat intervals pass with no response from the server.
>   
OK, thanks. This seems to help.

Is the option documented anywhere?

- Toralf


This e-mail, including any attachments and response string, may contain proprietary information which is confidential and may be legally privileged. It is for the intended recipient only. If you are not the intended recipient or transmission error has misdirected this e-mail, please notify the author by return e-mail and delete this message and any attachment immediately. If you are not the intended recipient you must not use, disclose, distribute, forward, copy, print or rely on this e-mail in any way except as permitted by the author.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: How to avoid waiting for a very long timeout on messaging::Connection::open()?

Posted by Gordon Sim <gs...@redhat.com>.
On 11/23/2011 09:05 AM, Toralf Lund wrote:
> Hello,
>
> Sometimes the host I'm connecting to via qpid::messaging::Connection
> turns out to be down. When this is the case, the open() call may exhibit
> two different kinds of behaviour, depending on the network configuration
> or something:
>
> 1. An exception is raised almost immediately, and a message like
> 2011-11-23 09:15:44 warning Connect failed: No route to host
> is logged.
> 2. An exception is raised after a *long* delay, and log message is
> 2011-11-23 09:25:01 warning Connect failed: Connection timed out
>
> Now, case 1) is not really much of an issue, but 2) is rather
> problematic because the timeout is something like 4 minutes, and I don't
> want to lock up my application for that long. Questions:
>
> 1. Why is it that I sometimes get "No route to host" and at other
> times have to wait for a timeout? Through what mechanism does the
> system (sometimes) know or find out directly that the remote host
> is missing, so that it doesn't have to wait for timeouts etc? I
> realise that this is more of a general sockets or TCP question
> than something specific to QPid or AMQP, but does anyone here know?
> 2. Is there any way to make the timeout for case 2) shorter? I tried
> setting the "reconnect-timeout" option on the connection, but this
> made no difference.

Set the heartbeat option, then the connection will abort if two 
heartbeat intervals pass with no response from the server.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org