You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by _cristian_ <cr...@gmail.com> on 2010/03/02 17:05:45 UTC

Connection.open get stuck with wrong host address

Hello.I have written a simple program that tries to open a connection to a
qpid broker. 
I am using qpid 0.5 on Centos5.4 x86_64.

I have the following code :
/* 
 * File:   main.cpp
 * Author: root
 *
 * Created on March 2, 2010, 4:49 PM
 */

#include <stdlib.h>
#include <qpid/client/Connection.h>
#include <qpid/client/Session.h>
#include <qpid/client/SubscriptionManager.h>

#include <string>
#include <stdexcept>
using namespace std;

int main(int argc, char** argv) {
    qpid::client::Connection connection;
    std::cout<<"Begin"<<std::endl;    
    try {
        connection.open("host", 5672, "user", "password");
    } catch( std::exception &e) {
        std::cout<<e.what()<<std::endl;
    } catch(...)  {
        std::cout<<"errors"<<std::endl;
    }    
    if( connection.isOpen() ) {
        std::cout<<"Opened"<<std::endl;
    }
    std::cout<<"exit"<<std::endl;
    return (EXIT_SUCCESS);
}
The problem is that if the first argument of connection.open is not a valid
host (for example an ip where there is no qpid broker) the program gets
stucked in the open() function. 
This is the gdb backtrace when the host parameter is not valid. The SIGINT
signal is caused by me pressing CTRL +C .

(gdb) run
Starting program: /root/NetBeansProjects/test/dist/Debug/GNU-Linux-x86/test 
[Thread debugging using libthread_db enabled]
[New Thread 0x2b9f6590f080 (LWP 18906)]
Begin

Program received signal SIGINT, Interrupt.
0x0000003fa14d44f0 in __connect_nocancel () from /lib64/libc.so.6
(gdb) bt
#0  0x0000003fa14d44f0 in __connect_nocancel () from /lib64/libc.so.6
#1  0x00002b9f64da7376 in qpid::sys::Socket::connect (this=0x2675030,
host=@0x2682228, p=<value optimized out>) at qpid/sys/posix/Socket.cpp:159
#2  0x00002b9f649cbb5d in qpid::client::TCPConnector::connect
(this=0x2674f40, host=@0x2682228, port=5672) at
qpid/client/Connector.cpp:189
#3  0x00002b9f649bfacb in qpid::client::ConnectionImpl::open
(this=0x2682130) at qpid/client/ConnectionImpl.cpp:137
#4  0x00002b9f649b26f9 in qpid::client::Connection::open
(this=0x7fff7c9ea390, settings=@0xffffffff) at
qpid/client/Connection.cpp:122
#5  0x00002b9f649b2dce in qpid::client::Connection::open
(this=0x7fff7c9ea390, host=@0x7fff7c9ea400, port=5672, uid=@0x7fff7c9ea3f0,
pwd=@0x7fff7c9ea3e0, 
    vhost=@0x7fff7c9ea3d0, maxFrameSize=65535) at
qpid/client/Connection.cpp:100
#6  0x0000000000402201 in main (argc=1, argv=0x7fff7c9ea518) at main.cpp:26


-- 
View this message in context: http://n2.nabble.com/Connection-open-get-stuck-with-wrong-host-address-tp4661786p4661786.html
Sent from the Apache Qpid developers mailing list archive at Nabble.com.

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


Re: Connection.open get stuck with wrong host address

Posted by Gordon Sim <gs...@redhat.com>.
On 03/03/2010 09:21 PM, _cristian_ wrote:
>
> It is implemented for qpidd 0.5?  or 0.6?

Heartbeats are implemented in 0.5 in general, but they did not take 
effect until after the connection was established and thus were not 
effective in preventing the wait you described. That issue has however 
also been addressed in 0.6 by starting the timeout before the connection 
is established.

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


Re: Connection.open get stuck with wrong host address

Posted by _cristian_ <cr...@gmail.com>.
It is implemented for qpidd 0.5?  or 0.6?
-- 
View this message in context: http://n2.nabble.com/Connection-open-get-stuck-with-wrong-host-address-tp4661786p4670557.html
Sent from the Apache Qpid developers mailing list archive at Nabble.com.

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


Re: Connection.open get stuck with wrong host address

Posted by Andrew Stitcher <as...@redhat.com>.
On Wed, 2010-03-03 at 00:41 -0800, _cristian_ wrote:
> You are right with the heartbeat options.But this option is not implemented
> yet. 

That's quite funny, as I implemented the feature myself.

> This is from apache qpid api docs: [
> http://qpid.apache.org/docs/api/cpp/html/a00226.html ]
> uint16_t 	heartbeat 	Allows a heartbeat frequency to be specified (this
> feature is not yet implemented). 
> After a period [ 2-3 minutes ] connection.open return and i get the message:
> Connection timed out: 10.10.5.5:5672 (qpid/sys/posix/Socket.cpp:162)
> 
> Thanks for your help guys



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


Re: Connection.open get stuck with wrong host address

Posted by _cristian_ <cr...@gmail.com>.
Thank you for your help. i will upgrade when 0.6 will be released
-- 
View this message in context: http://n2.nabble.com/Connection-open-get-stuck-with-wrong-host-address-tp4661786p4666970.html
Sent from the Apache Qpid developers mailing list archive at Nabble.com.

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


Re: Connection.open get stuck with wrong host address

Posted by Gordon Sim <gs...@redhat.com>.
On 03/03/2010 11:37 AM, _cristian_ wrote:
>
> It is 0.5
> This is  the output for: qpidd -v
> qpidd (qpidc) version 0.5

Ok, that is fixed on trunk and will be in the 0.6 release.

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


Re: Connection.open get stuck with wrong host address

Posted by _cristian_ <cr...@gmail.com>.
It is 0.5
This is  the output for: qpidd -v
qpidd (qpidc) version 0.5


-- 
View this message in context: http://n2.nabble.com/Connection-open-get-stuck-with-wrong-host-address-tp4661786p4666929.html
Sent from the Apache Qpid developers mailing list archive at Nabble.com.

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


Re: Connection.open get stuck with wrong host address

Posted by Gordon Sim <gs...@redhat.com>.
On 03/03/2010 11:26 AM, _cristian_ wrote:
>
> Was this when using a non-zero heartbeat?
> Yes.I have heartbeat=10.
> open() returns after 3 minutes, even with heartbeat=10.

Is this using 0.5? I believe there was a fix made after that to deal 
with the opening of the connection (prior to the fix heartbeats were 
only enabled once the connection was opened).


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


Re: Connection.open get stuck with wrong host address

Posted by _cristian_ <cr...@gmail.com>.
Was this when using a non-zero heartbeat? 
Yes.I have heartbeat=10. 
open() returns after 3 minutes, even with heartbeat=10.
-- 
View this message in context: http://n2.nabble.com/Connection-open-get-stuck-with-wrong-host-address-tp4661786p4666883.html
Sent from the Apache Qpid developers mailing list archive at Nabble.com.

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


Re: Connection.open get stuck with wrong host address

Posted by Gordon Sim <gs...@redhat.com>.
On 03/03/2010 08:41 AM, _cristian_ wrote:
>
> You are right with the heartbeat options.But this option is not implemented
> yet.

Those docs are out of date. Heartbeats are implemented.

> This is from apache qpid api docs: [
> http://qpid.apache.org/docs/api/cpp/html/a00226.html ]
> uint16_t 	heartbeat 	Allows a heartbeat frequency to be specified (this
> feature is not yet implemented).
> After a period [ 2-3 minutes ] connection.open return and i get the message:
> Connection timed out: 10.10.5.5:5672 (qpid/sys/posix/Socket.cpp:162)

Was this when using a non-zero heartbeat?

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


Re: Connection.open get stuck with wrong host address

Posted by _cristian_ <cr...@gmail.com>.
You are right with the heartbeat options.But this option is not implemented
yet. 
This is from apache qpid api docs: [
http://qpid.apache.org/docs/api/cpp/html/a00226.html ]
uint16_t 	heartbeat 	Allows a heartbeat frequency to be specified (this
feature is not yet implemented). 
After a period [ 2-3 minutes ] connection.open return and i get the message:
Connection timed out: 10.10.5.5:5672 (qpid/sys/posix/Socket.cpp:162)

Thanks for your help guys
-- 
View this message in context: http://n2.nabble.com/Connection-open-get-stuck-with-wrong-host-address-tp4661786p4666291.html
Sent from the Apache Qpid developers mailing list archive at Nabble.com.

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


Re: Connection.open get stuck with wrong host address

Posted by Andrew Stitcher <as...@redhat.com>.
On Tue, 2010-03-02 at 08:05 -0800, _cristian_ wrote:
> Hello.I have written a simple program that tries to open a connection to a
> qpid broker. 
> I am using qpid 0.5 on Centos5.4 x86_64.
> ...
> The problem is that if the first argument of connection.open is not a valid
> host (for example an ip where there is no qpid broker) the program gets
> stucked in the open() function. 
> This is the gdb backtrace when the host parameter is not valid. The SIGINT
> signal is caused by me pressing CTRL +C .

This is exactly what you would expect, and indeed would be precisely the
behaviour you will get if you opened any TCP connection to a non
existent address [using a normal blocking connect()]

If you need to timeout a connection in progress you should set a
heartbeat timeout on the Connection. use the connections settings to do
this:

ConnectionSettings settings;
settings.heartbeat = 10; // 20 second timeout
settings.host = "host";
settings.username = "user";
settings.password = "password";
connection.open(settings);

That should enable you to timeout an unsuccessful  connection.

Andrew



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


RE: Connection.open get stuck with wrong host address

Posted by Steve Huston <sh...@riverace.com>.
I think you may be seeing the effect of the connect() call trying to
contact a host that it can't readily contact. It should time out in a
minute or two.

-Steve

--
Steve Huston, Riverace Corporation
Total Lifecycle Support for Your Networked Applications
http://www.riverace.com


> -----Original Message-----
> From: _cristian_ [mailto:cristian.sorinel@gmail.com] 
> Sent: Tuesday, March 02, 2010 11:06 AM
> To: dev@qpid.apache.org
> Subject: Connection.open get stuck with wrong host address
> 
> 
> 
> Hello.I have written a simple program that tries to open a 
> connection to a qpid broker. 
> I am using qpid 0.5 on Centos5.4 x86_64.
> 
> I have the following code :
> /* 
>  * File:   main.cpp
>  * Author: root
>  *
>  * Created on March 2, 2010, 4:49 PM
>  */
> 
> #include <stdlib.h>
> #include <qpid/client/Connection.h>
> #include <qpid/client/Session.h>
> #include <qpid/client/SubscriptionManager.h>
> 
> #include <string>
> #include <stdexcept>
> using namespace std;
> 
> int main(int argc, char** argv) {
>     qpid::client::Connection connection;
>     std::cout<<"Begin"<<std::endl;    
>     try {
>         connection.open("host", 5672, "user", "password");
>     } catch( std::exception &e) {
>         std::cout<<e.what()<<std::endl;
>     } catch(...)  {
>         std::cout<<"errors"<<std::endl;
>     }    
>     if( connection.isOpen() ) {
>         std::cout<<"Opened"<<std::endl;
>     }
>     std::cout<<"exit"<<std::endl;
>     return (EXIT_SUCCESS);
> }
> The problem is that if the first argument of connection.open 
> is not a valid host (for example an ip where there is no qpid 
> broker) the program gets stucked in the open() function. 
> This is the gdb backtrace when the host parameter is not 
> valid. The SIGINT signal is caused by me pressing CTRL +C .
> 
> (gdb) run
> Starting program: 
> /root/NetBeansProjects/test/dist/Debug/GNU-Linux-x86/test 
> [Thread debugging using libthread_db enabled]
> [New Thread 0x2b9f6590f080 (LWP 18906)]
> Begin
> 
> Program received signal SIGINT, Interrupt.
> 0x0000003fa14d44f0 in __connect_nocancel () from /lib64/libc.so.6
> (gdb) bt
> #0  0x0000003fa14d44f0 in __connect_nocancel () from 
> /lib64/libc.so.6 #1  0x00002b9f64da7376 in 
> qpid::sys::Socket::connect (this=0x2675030, host=@0x2682228, 
> p=<value optimized out>) at qpid/sys/posix/Socket.cpp:159 #2  
> 0x00002b9f649cbb5d in qpid::client::TCPConnector::connect
> (this=0x2674f40, host=@0x2682228, port=5672) at 
> qpid/client/Connector.cpp:189 #3  0x00002b9f649bfacb in 
> qpid::client::ConnectionImpl::open
> (this=0x2682130) at qpid/client/ConnectionImpl.cpp:137
> #4  0x00002b9f649b26f9 in qpid::client::Connection::open 
> (this=0x7fff7c9ea390, settings=@0xffffffff) at 
> qpid/client/Connection.cpp:122 #5  0x00002b9f649b2dce in 
> qpid::client::Connection::open (this=0x7fff7c9ea390, 
> host=@0x7fff7c9ea400, port=5672, uid=@0x7fff7c9ea3f0, 
> pwd=@0x7fff7c9ea3e0, 
>     vhost=@0x7fff7c9ea3d0, maxFrameSize=65535) at 
> qpid/client/Connection.cpp:100 #6  0x0000000000402201 in main 
> (argc=1, argv=0x7fff7c9ea518) at main.cpp:26
> 
> 
> -- 
> View this message in context: 
> http://n2.nabble.com/Connection-open-get-stuck-with-wrong-host
-address-tp4661786p4661786.html
Sent from the Apache Qpid developers mailing list archive at Nabble.com.

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



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