You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by BoomBoom49 <Bo...@gmail.com> on 2012/10/18 17:58:15 UTC

[MQTT] Impossible to disable InactivityMonitor !

Hi,

I try to migrate from mosquitto to ActiveMQ 5.7.0, 
  - I configure my xml with 
  - my java client send a CONNECT message with a keepAlive set to 0.

but ActivateMQ kill my connection after 30s with a nice 


When I set a keep alive to 60sec, it works. I mean ActiveMQ kill my
connection after 60secs.

I have a look to the source of MQTTInactivityMonitor and
MQTTProtocolConverter
and it seem impossible to start a MQTTInactivityMonitor with a 0 keepAlive,
but in my log I have this message :


So I really don't understand.

Thx



--
View this message in context: http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi,

can you raise a Jira for this? Thanks.

Regards
--
Dejan Bosanac
----------------------
Red Hat, Inc.
FuseSource is now part of Red Hat
dbosanac@redhat.com
Twitter: @dejanb
Blog: http://sensatic.net
ActiveMQ in Action: http://www.manning.com/snyder/


On Thu, Oct 18, 2012 at 5:58 PM, BoomBoom49 <Bo...@gmail.com> wrote:
> Hi,
>
> I try to migrate from mosquitto to ActiveMQ 5.7.0,
>   - I configure my xml with
>   - my java client send a CONNECT message with a keepAlive set to 0.
>
> but ActivateMQ kill my connection after 30s with a nice
>
>
> When I set a keep alive to 60sec, it works. I mean ActiveMQ kill my
> connection after 60secs.
>
> I have a look to the source of MQTTInactivityMonitor and
> MQTTProtocolConverter
> and it seem impossible to start a MQTTInactivityMonitor with a 0 keepAlive,
> but in my log I have this message :
>
>
> So I really don't understand.
>
> Thx
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by Charles Wang <ki...@gmail.com>.
Thanks, i'm working on it.

On Oct 26, 2012, at 4:12 AM, ceposta [via ActiveMQ] <ml...@n4.nabble.com> wrote:

> Charles, 
> wireFormat.maxInactivityDuration won't work for MQTT 
> Can you try on the latest snapshots using the KeepAlive setting in the 
> client? 
> 
> On Mon, Oct 22, 2012 at 1:20 AM, Charles Wang <[hidden email]> wrote: 
> 
> > i'm using the 5.8.0-snapshot, my setting: 
> > 
> > <transportConnector name="mqtt" 
> > uri="mqtt://113.31.65.60:1883?wireFormat.maxInactivityDuration=0"/> 
> > 
> > And i got: 
> > 
> > 2012-10-22 16:10:45,674 | DEBUG | SampleJavaV3_subscribe MQTT Connection 
> > using heart beat of  60 secs | 
> > org.apache.activemq.transport.mqtt.MQTTProtocolConverter | ActiveMQ 
> > Transport: tcp:///124.127.108.134:7442@1883 
> > 2012-10-22 16:10:45,699 | DEBUG | MQTT Client  connected. | 
> > org.apache.activemq.transport.mqtt.MQTTProtocolConverter | ActiveMQ 
> > Transport: tcp:///124.127.108.134:7442@1883 
> > 2012-10-22 16:12:45,674 | DEBUG | 60000 ms elapsed since last read check. | 
> > org.apache.activemq.transport.mqtt.MQTTInactivityMonitor | 
> > InactivityMonitor 
> > ReadCheck 
> > 2012-10-22 16:12:45,709 | DEBUG | Sent Ping Response to  | 
> > org.apache.activemq.transport.mqtt.MQTTProtocolConverter | ActiveMQ 
> > Transport: tcp:///124.127.108.134:7442@1883 
> > 2012-10-22 16:13:45,675 | DEBUG | 60001 ms elapsed since last read check. | 
> > org.apache.activemq.transport.mqtt.MQTTInactivityMonitor | 
> > InactivityMonitor 
> > ReadCheck 
> > 2012-10-22 16:14:45,675 | DEBUG | 60000 ms elapsed since last read check. | 
> > org.apache.activemq.transport.mqtt.MQTTInactivityMonitor | 
> > InactivityMonitor 
> > ReadCheck 
> > 2012-10-22 16:14:45,675 | DEBUG | No message received since last read check 
> > for tcp:///124.127.108.134:7442@1883! Throwing InactivityIOException. | 
> > org.apache.activemq.transport.mqtt.MQTTInactivityMonitor | 
> > InactivityMonitor 
> > ReadCheck 
> > 2012-10-22 16:14:45,677 | WARN  | Transport Connection to: 
> > tcp://124.127.108.134:7442 failed: 
> > org.apache.activemq.transport.InactivityIOException: Channel was inactive 
> > for too (>60000) long: tcp://124.127.108.134:7442 | 
> > org.apache.activemq.broker.TransportConnection.Transport | 
> > MQTTInactivityMonitor Async Task: 
> > java.util.concurrent.ThreadPoolExecutor$Worker@6e659812[State = 0, empty 
> > queue] 
> > 
> > 
> > 
> > -- 
> > View this message in context: 
> > http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4658032.html
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com. 
> >
> 
> 
> 
> -- 
> *Christian Posta* 
> http://www.christianposta.com/blog
> twitter: @christianposta 
> http://www.christianposta.com/blog
> 
> 
> If you reply to this email, your message will be added to the discussion below:
> http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4658249.html
> To unsubscribe from [MQTT] Impossible to disable InactivityMonitor !, click here.
> NAML





--
View this message in context: http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4658277.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by Christian Posta <ch...@gmail.com>.
Charles,
wireFormat.maxInactivityDuration won't work for MQTT
Can you try on the latest snapshots using the KeepAlive setting in the
client?

On Mon, Oct 22, 2012 at 1:20 AM, Charles Wang <ki...@gmail.com> wrote:

> i'm using the 5.8.0-snapshot, my setting:
>
> <transportConnector name="mqtt"
> uri="mqtt://113.31.65.60:1883?wireFormat.maxInactivityDuration=0"/>
>
> And i got:
>
> 2012-10-22 16:10:45,674 | DEBUG | SampleJavaV3_subscribe MQTT Connection
> using heart beat of  60 secs |
> org.apache.activemq.transport.mqtt.MQTTProtocolConverter | ActiveMQ
> Transport: tcp:///124.127.108.134:7442@1883
> 2012-10-22 16:10:45,699 | DEBUG | MQTT Client  connected. |
> org.apache.activemq.transport.mqtt.MQTTProtocolConverter | ActiveMQ
> Transport: tcp:///124.127.108.134:7442@1883
> 2012-10-22 16:12:45,674 | DEBUG | 60000 ms elapsed since last read check. |
> org.apache.activemq.transport.mqtt.MQTTInactivityMonitor |
> InactivityMonitor
> ReadCheck
> 2012-10-22 16:12:45,709 | DEBUG | Sent Ping Response to  |
> org.apache.activemq.transport.mqtt.MQTTProtocolConverter | ActiveMQ
> Transport: tcp:///124.127.108.134:7442@1883
> 2012-10-22 16:13:45,675 | DEBUG | 60001 ms elapsed since last read check. |
> org.apache.activemq.transport.mqtt.MQTTInactivityMonitor |
> InactivityMonitor
> ReadCheck
> 2012-10-22 16:14:45,675 | DEBUG | 60000 ms elapsed since last read check. |
> org.apache.activemq.transport.mqtt.MQTTInactivityMonitor |
> InactivityMonitor
> ReadCheck
> 2012-10-22 16:14:45,675 | DEBUG | No message received since last read check
> for tcp:///124.127.108.134:7442@1883! Throwing InactivityIOException. |
> org.apache.activemq.transport.mqtt.MQTTInactivityMonitor |
> InactivityMonitor
> ReadCheck
> 2012-10-22 16:14:45,677 | WARN  | Transport Connection to:
> tcp://124.127.108.134:7442 failed:
> org.apache.activemq.transport.InactivityIOException: Channel was inactive
> for too (>60000) long: tcp://124.127.108.134:7442 |
> org.apache.activemq.broker.TransportConnection.Transport |
> MQTTInactivityMonitor Async Task:
> java.util.concurrent.ThreadPoolExecutor$Worker@6e659812[State = 0, empty
> queue]
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4658032.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by Charles Wang <ki...@gmail.com>.
i'm using the 5.8.0-snapshot, my setting:

<transportConnector name="mqtt"
uri="mqtt://113.31.65.60:1883?wireFormat.maxInactivityDuration=0"/>

And i got:

2012-10-22 16:10:45,674 | DEBUG | SampleJavaV3_subscribe MQTT Connection
using heart beat of  60 secs |
org.apache.activemq.transport.mqtt.MQTTProtocolConverter | ActiveMQ
Transport: tcp:///124.127.108.134:7442@1883
2012-10-22 16:10:45,699 | DEBUG | MQTT Client  connected. |
org.apache.activemq.transport.mqtt.MQTTProtocolConverter | ActiveMQ
Transport: tcp:///124.127.108.134:7442@1883
2012-10-22 16:12:45,674 | DEBUG | 60000 ms elapsed since last read check. |
org.apache.activemq.transport.mqtt.MQTTInactivityMonitor | InactivityMonitor
ReadCheck
2012-10-22 16:12:45,709 | DEBUG | Sent Ping Response to  |
org.apache.activemq.transport.mqtt.MQTTProtocolConverter | ActiveMQ
Transport: tcp:///124.127.108.134:7442@1883
2012-10-22 16:13:45,675 | DEBUG | 60001 ms elapsed since last read check. |
org.apache.activemq.transport.mqtt.MQTTInactivityMonitor | InactivityMonitor
ReadCheck
2012-10-22 16:14:45,675 | DEBUG | 60000 ms elapsed since last read check. |
org.apache.activemq.transport.mqtt.MQTTInactivityMonitor | InactivityMonitor
ReadCheck
2012-10-22 16:14:45,675 | DEBUG | No message received since last read check
for tcp:///124.127.108.134:7442@1883! Throwing InactivityIOException. |
org.apache.activemq.transport.mqtt.MQTTInactivityMonitor | InactivityMonitor
ReadCheck
2012-10-22 16:14:45,677 | WARN  | Transport Connection to:
tcp://124.127.108.134:7442 failed:
org.apache.activemq.transport.InactivityIOException: Channel was inactive
for too (>60000) long: tcp://124.127.108.134:7442 |
org.apache.activemq.broker.TransportConnection.Transport |
MQTTInactivityMonitor Async Task:
java.util.concurrent.ThreadPoolExecutor$Worker@6e659812[State = 0, empty
queue]



--
View this message in context: http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4658032.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by Aliquip <al...@gmail.com>.
Thanks for all the effort! I'm really happy to finally have the mqtt
transport working.



--
View this message in context: http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4658131.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by Timothy Bish <ta...@gmail.com>.
On Tue, 2012-10-23 at 11:02 -0700, Aliquip wrote: 
> It's solved partially. The problem is fixed when _not_ using mqtt over nio.
> When using nio, the inactivitymonitor disconnects again.
> 
> 

That should get fixed as a result of my fixes for:
https://issues.apache.org/jira/browse/AMQ-4106

The problem is basically the same, so I'll make sure to add that on this
fix. 

> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4658119.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.fusesource.com | www.redhat.com 
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by Aliquip <al...@gmail.com>.
It's solved partially. The problem is fixed when _not_ using mqtt over nio.
When using nio, the inactivitymonitor disconnects again.



--
View this message in context: http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4658119.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by Christian Posta <ch...@gmail.com>.
On Sat, Oct 20, 2012 at 7:47 AM, Aliquip <al...@gmail.com> wrote:

> After testing and comparing with mosquitto (http://mosquitto.org) using
> mosquitto's python client the behavior is still different (and not very
> usable, sadly)
>
> Connecting with keepalive=0 results in the _client_ disconnecting
> immediately from the server (either mosquitto or activemq). So setting keep
> alive to 0 in the client isn't the way to keep the connection open forever.
>
> Connecting with keepalive=x (x > 0) results in the client keeping the
> connection open sending ping's every x seconds. If no PINGRESP is received
> after x seconds, the _client_ closes the connection. The mosquitto server
> keeps the connection open as long as pings are exchanged. The activemq
> server closes the connection after x seconds despite pings being received,
> it only keeps the connection open if other messages than pings are
> received.
>
> Maybe the (short term) solution is to make pings reset the countdown of the
> inactivity monitor, just like normal messages reset the countdown.
>
Can you try on the latest trunk? This behavior should be the case now with
https://issues.apache.org/jira/browse/AMQ-4117 fixed



>
> I'm not really familiar with the MQTT (or activemq for that matter)
> protocol, but to me the problem seems to lie in the fact that in the MQTT
> protocol there is no such thing as keepalive / inactivitymonitor.
> Connections are kept open forever despite inactivity (when inactivity is
> defined as no messages except pingreq/pingresp). There is no way to clean
> unused connections in the way inactivitymonitor tries to do. Only a raw
> disconnect or a failure to ping disconnects a connection.
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4658026.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog

Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by andypiper <an...@gmail.com>.
Aliquip wrote
> After testing and comparing with mosquitto (http://mosquitto.org) using
> mosquitto's python client the behavior is still different (and not very
> usable, sadly)
> ...
> I'm not really familiar with the MQTT (or activemq for that matter)
> protocol, but to me the problem seems to lie in the fact that in the MQTT
> protocol there is no such thing as keepalive / inactivitymonitor.
> Connections are kept open forever despite inactivity (when inactivity is
> defined as no messages except pingreq/pingresp). There is no way to clean
> unused connections in the way inactivitymonitor tries to do. Only a raw
> disconnect or a failure to ping disconnects a connection.

Probably the best place to get to the bottom of this is the MQTT discussion
group on Google Groups.

>From my own perspective, Really Small Message Broker and mosquitto are
typically seen as the most widely used / tested / compliant broker
implementations, although it's true that a number of clarifications to the
published specification have been made via the mailing list and mqtt.org
wiki.

If there is uncertainty about the expected behaviour, a quick exchange on
the MQTT group is usually sufficient to clarify with the authors of the
original implementation and spec.

Andy




-----
Andy Piper
Eclipse Paho Committer / mqtt.org community lead
http://andypiper.co.uk
--
View this message in context: http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4658029.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by Aliquip <al...@gmail.com>.
After testing and comparing with mosquitto (http://mosquitto.org) using
mosquitto's python client the behavior is still different (and not very
usable, sadly)

Connecting with keepalive=0 results in the _client_ disconnecting
immediately from the server (either mosquitto or activemq). So setting keep
alive to 0 in the client isn't the way to keep the connection open forever.

Connecting with keepalive=x (x > 0) results in the client keeping the
connection open sending ping's every x seconds. If no PINGRESP is received
after x seconds, the _client_ closes the connection. The mosquitto server
keeps the connection open as long as pings are exchanged. The activemq
server closes the connection after x seconds despite pings being received,
it only keeps the connection open if other messages than pings are received.

Maybe the (short term) solution is to make pings reset the countdown of the
inactivity monitor, just like normal messages reset the countdown.

I'm not really familiar with the MQTT (or activemq for that matter)
protocol, but to me the problem seems to lie in the fact that in the MQTT
protocol there is no such thing as keepalive / inactivitymonitor.
Connections are kept open forever despite inactivity (when inactivity is
defined as no messages except pingreq/pingresp). There is no way to clean
unused connections in the way inactivitymonitor tries to do. Only a raw
disconnect or a failure to ping disconnects a connection.




--
View this message in context: http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4658026.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by Timothy Bish <ta...@gmail.com>.
On Fri, 2012-10-19 at 14:21 -0700, Aliquip wrote: 
> Isn't InactivityMonitor there to to throw out completely dead connections,
> thus connections where no ping's are exachanged?
> 
> Reading http://activemq.apache.org/activemq-inactivitymonitor.html "If
> normal activemq traffic has not been sent across the connection during that
> period, it expects to receive a KeepAliveInfo message sent by the
> InactivityMonitor on the other end of the connection." Now the mqtt protocol
> doesnt know of KeepAliveInfo, it however does implement ping messages.
> 
> I stumbled on a similar problem, where it seemed that, despite ping's being
> exchanged the connection was closed
> (http://activemq.2283324.n4.nabble.com/ActiveMQ-5-7-snapshot-and-MQTT-connection-times-out-while-still-connected-to-a-topic-for-receiving-td4656976.html)
> 
> 

I just applied a fix to the MQTT code that fixes the startup of the MQTT
version of the Inactivity Monitor such that it will honor the keep alive
setting sent in the CONNECT frame.  Prior to this it was always started
early with the default 30 second timeout.  If you set the keepAlive to
zero it should now not disconnect your client.  We should probably look
to enhance this in the future such that a client that sets a zero keep
alive interval still has some inactivity tracking done so that we can
close down dead socket connections after some longer read timeout.  

See: https://issues.apache.org/jira/browse/AMQ-4117

> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4657999.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.fusesource.com | www.redhat.com 
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by Aliquip <al...@gmail.com>.
Isn't InactivityMonitor there to to throw out completely dead connections,
thus connections where no ping's are exachanged?

Reading http://activemq.apache.org/activemq-inactivitymonitor.html "If
normal activemq traffic has not been sent across the connection during that
period, it expects to receive a KeepAliveInfo message sent by the
InactivityMonitor on the other end of the connection." Now the mqtt protocol
doesnt know of KeepAliveInfo, it however does implement ping messages.

I stumbled on a similar problem, where it seemed that, despite ping's being
exchanged the connection was closed
(http://activemq.2283324.n4.nabble.com/ActiveMQ-5-7-snapshot-and-MQTT-connection-times-out-while-still-connected-to-a-topic-for-receiving-td4656976.html)



--
View this message in context: http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4657999.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by BoomBoom49 <Bo...@gmail.com>.
I thought too, that wireFormat.maxInactivityDuration=0 doesn't have effect on
server side.
Now I have confirmation. Thx

It will be my coworker who will create the JIRA.



--
View this message in context: http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945p4657985.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: [MQTT] Impossible to disable InactivityMonitor !

Posted by Christian Posta <ch...@gmail.com>.
Let me know what the JIRA is when you open it.
The wireFormat.maxInactivityDuration=0 option to the connector is not
observed for MQTT in the current code base. Still not sure that it matters,
but I'll check.

I tried to reproduce on the latest code base, but cannot reproduce exactly
as you've described. I'll try again on 5.7.

On Thu, Oct 18, 2012 at 8:58 AM, BoomBoom49 <Bo...@gmail.com> wrote:

> Hi,
>
> I try to migrate from mosquitto to ActiveMQ 5.7.0,
>   - I configure my xml with
>   - my java client send a CONNECT message with a keepAlive set to 0.
>
> but ActivateMQ kill my connection after 30s with a nice
>
>
> When I set a keep alive to 60sec, it works. I mean ActiveMQ kill my
> connection after 60secs.
>
> I have a look to the source of MQTTInactivityMonitor and
> MQTTProtocolConverter
> and it seem impossible to start a MQTTInactivityMonitor with a 0 keepAlive,
> but in my log I have this message :
>
>
> So I really don't understand.
>
> Thx
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/MQTT-Impossible-to-disable-InactivityMonitor-tp4657945.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog