You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by dominate <do...@yahoo.com> on 2017/01/02 21:01:26 UTC

[Qpid Proton 0.14] how can i reconnect after timeout?

I start my default container: proton::default_container
I have a idle timeout and after that time, correctly on_transport_close
event is called.
But then, nothing !!
What should I do?
How can i reconnect, especially, manually?
In on_transport_close I tried to stop container, but nothing happens:

proton::default_container(handler).auto_stop(true);
proton::default_container(handler).stop();
conn->unsafe().close();

Thank you!



--
View this message in context: http://qpid.2158936.n2.nabble.com/Qpid-Proton-0-14-how-can-i-reconnect-after-timeout-tp7657154.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


RE: [Qpid Proton 0.14] how can i reconnect after timeout?

Posted by Jeff Donner <jd...@morphodetection.com>.
If you pass that container as a pointer or reference to the handler, then from that handler, on an error, you can call:

  stored_ptr_to_container_->stop();

But you say that this doesn't work? 

Another way you can quit the loop is to throw some exception from your handler and catch it outside the call: 

for (;;) {
  try {
    default_container(handler).run();  
  }
  catch (WhateverException& whatever) {
    // choose to handle and keep running, or leave the for (;;) loop
  }
  catch (many other exceptions& ...) {
  }
}

Given that you describe a natural end-of-life for the connection though, there's probably a more proper way. Maybe some return value from a handler? (haven't checked.)


________________________________________
From: dominate [dominate_mats@yahoo.com]
Sent: Saturday, January 07, 2017 12:37 PM
To: users@qpid.apache.org
Subject: Re: [Qpid Proton 0.14] how can i reconnect after timeout?

Sorry maybe I did not explain clearly.

When we make default_container::run, handler is run another thread, right?
Then, when I receive on_transport_close event, what I expect is that the
thread of handler ends so that I could resume from next line to the
default_container::run.
So, to try what could make handler thread return, I have tried every thing,
stopping container etc.

i.e.

(I write as pseudo syntax)

default_container(handler).run();
// it NEVER comes to this line! run never returns!

How can I achieve that the handler returns when I detect error?
Thank you very much!



--
View this message in context: http://qpid.2158936.n2.nabble.com/Qpid-Proton-0-14-how-can-i-reconnect-after-timeout-tp7657154p7657513.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: [Qpid Proton 0.14] how can i reconnect after timeout?

Posted by dominate <do...@yahoo.com>.
Sorry maybe I did not explain clearly.

When we make default_container::run, handler is run another thread, right?
Then, when I receive on_transport_close event, what I expect is that the
thread of handler ends so that I could resume from next line to the
default_container::run.
So, to try what could make handler thread return, I have tried every thing,
stopping container etc.

i.e.

(I write as pseudo syntax)

default_container(handler).run();
// it NEVER comes to this line! run never returns!

How can I achieve that the handler returns when I detect error?
Thank you very much!



--
View this message in context: http://qpid.2158936.n2.nabble.com/Qpid-Proton-0-14-how-can-i-reconnect-after-timeout-tp7657154p7657513.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: [Qpid Proton 0.14] how can i reconnect after timeout?

Posted by Andrew Stitcher <as...@redhat.com>.
On Mon, 2017-01-02 at 14:01 -0700, dominate wrote:
> I start my default container: proton::default_container
> I have a idle timeout and after that time, correctly
> on_transport_close
> event is called.
> But then, nothing !!
> What should I do?
> How can i reconnect, especially, manually?
> In on_transport_close I tried to stop container, but nothing happens:

Do you mean that the process hung? If so this is a known bug in
previous versions of proton-c. It should be fixed in 0.16.

However you don't need to close the container to reconnect, and in fact
it doesn't really make much sense. For the vast majority of client
applications you create a single container for the entire lifetime of
the application itself. All you should need to do is to respond to
on_connection_close by rerunning the same connect that you did
originally. You will probably want to schedule this connect in the
future to avoid busy looping.

There is currently no automatic way to handle these reconnects, but it
is something we will be looking at soon.

Andrew




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org