ActiveMQ heart beats

701 views
Skip to first unread message

Chris Northwood

unread,
Jan 13, 2015, 4:04:00 PM1/13/15
to openraildata-talk
Hi all,

I've been putting together a queue consumer which uses the VSTP feed. I'm using the library stomp.py which manages heart beats for me, and I'm finding that I'm not receiving heart beats.

Here's my code:


The library I'm using, stomp.py manages heart beats for me. When I run the code, I get this output:

[2015-01-13 20:51:57,280] stomp.py     INFO     Attempting connection to host datafeeds.networkrail.co.uk, port 61618

[2015-01-13 20:51:57,536] stomp.py     INFO     Established connection to host datafeeds.networkrail.co.uk, port 61618

[2015-01-13 20:51:57,537] stomp.py     DEBUG    listener <medlock.importers.network_rail_vstp.NetworkRailVstpImporter object at 0x7f7b58910d10> has no method on_connecting

[2015-01-13 20:51:57,537] stomp.py     INFO     Sending frame ['STOMP', '\n', 'accept-version:1.1\n', 'heart-beat:5000,10000\n', 'host:datafeeds.networkrail.co.uk\n', 'login:xxx\n', 'passcode:xxx\n', '\n', '\x00']

[2015-01-13 20:51:57,538] stomp.py     INFO     Starting receiver loop

[2015-01-13 20:51:57,646] stomp.py     INFO     Sending frame ['SUBSCRIBE', '\n', 'ack:client-individual\n', 'destination:/topic/VSTP_ALL\n', 'id:granny-smith.config-vstp\n', '\n', '\x00']

[2015-01-13 20:51:57,647] stomp.py     DEBUG    listener <medlock.importers.network_rail_vstp.NetworkRailVstpImporter object at 0x7f7b58910d10> has no method on_connected

[2015-01-13 20:51:57,647] stomp.py     INFO     Received frame: 'CONNECTED', headers={'session': 'ID:ec2netrailprodmaster1-37182-1421164873348-2:6810', 'version': '1.1', 'server': 'ActiveMQ/5.8.0', 'heart-beat': '10000,5000'}, body=''

[2015-01-13 20:52:07,663] stomp.py     DEBUG    Sending a heartbeat message at 1421182327.66

[2015-01-13 20:52:07,663] stomp.py     INFO     Sending frame ['\n']

[2015-01-13 20:52:09,666] stomp.py     INFO     Heartbeat timeout: diff_receive=12.0194880962, diff_heartbeat=12.0194880962, time=1421182329.67, lastrec=1421182317.65

[2015-01-13 20:52:09,667] stomp.py     INFO     Receiver loop ended

Has anyone else experienced this? Subscribing to a higher-traffic topic does seem to behave correctly but right now I only need the VSTP feed. Are my heart beat times realistic? Looking at the headers suggests that ActiveMQ 5.8 is in use, and there appears to be a bug in 5.8 regarding heart beats: https://issues.apache.org/jira/browse/AMQ-4710

Any advice gratefully received!

Chris

Peter Hicks

unread,
Jan 13, 2015, 4:44:44 PM1/13/15
to openrail...@googlegroups.com
Hi Chris

On 13/01/15 21:03, Chris Northwood wrote:
> I've been putting together a queue consumer which uses the VSTP feed.
> I'm using the library stomp.py which manages heart beats for me, and
> I'm finding that I'm not receiving heart beats.
> [cut]
I've run up a client here and connected to the VSTP topic - heartbeats
are coming back and forth fine:

pwh@angel:bin% ./vstp-poller.rb
2015-01-13 21:40:21 +0000 DEBUG Logger initialized
2015-01-13 21:40:21 +0000 DEBUG Connecting: host=datafeeds.networkrail.co.uk
2015-01-13 21:40:21 +0000 DEBUG Connected: host=datafeeds.networkrail.co.uk
2015-01-13 21:40:21 +0000 DEBUG Subscribed -
params=host=datafeeds.networkrail.co.uk,
headers={:id=>"8e86c7d7546a4e6a46a73ae91fc9eded805f66c1",
:destination=>"/topic/VSTP_ALL"}
2015-01-13 21:40:26 +0000 DEBUG Heartbeat fired -
params=host=datafeeds.networkrail.co.uk, srind=send_fire
2015-01-13 21:40:26 +0000 DEBUG Heartbeat fired -
params=host=datafeeds.networkrail.co.uk, srind=send_heartbeat
2015-01-13 21:40:31 +0000 DEBUG Heartbeat fired -
params=host=datafeeds.networkrail.co.uk, srind=receive_fire
2015-01-13 21:40:31 +0000 DEBUG Heartbeat fired -
params=host=datafeeds.networkrail.co.uk, srind=send_fire
2015-01-13 21:40:31 +0000 DEBUG Heartbeat fired -
params=host=datafeeds.networkrail.co.uk, srind=receive_heartbeat
2015-01-13 21:40:31 +0000 DEBUG Heartbeat fired -
params=host=datafeeds.networkrail.co.uk, srind=send_heartbeat
2015-01-13 21:40:36 +0000 DEBUG Heartbeat fired -
params=host=datafeeds.networkrail.co.uk, srind=send_fire
2015-01-13 21:40:36 +0000 DEBUG Heartbeat fired -
params=host=datafeeds.networkrail.co.uk, srind=send_heartbeat
...

It doesn't *look* like the bug you referenced, however it could be a
problem with stomp.py.

I don't grok Python - any chance you could email me an "all in one"
script I can run here so I can compare the messages sent by stomp.py
with those send by a Ruby client?

Cheers,


Peter

Chris Northwood

unread,
Jan 13, 2015, 4:59:14 PM1/13/15
to Peter Hicks, openraildata-talk
Thanks Peter: https://gist.github.com/cnorthwood/323534c9df8230d6bbeb is an all-in-one script (requires you to install stomp.py). The script configures a debug logger which shows exactly what frames are sent/received. I wonder if the Ruby script you have can do similar, one difference I see is the 'send_fire' that the Ruby script appears to do, I'm not sure what that corresponds to?




--
You received this message because you are subscribed to the Google Groups "A gathering place for the Open Rail Data community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openraildata-talk+unsubscribe@googlegroups.com.
To post to this group, send an email to openraildata-talk@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris Northwood

unread,
Jan 13, 2015, 5:06:57 PM1/13/15
to Peter Hicks, openraildata-talk
Hmm, changing the heart beat to 10000,5000 (So I should send every 10 secs, server every 5) stops my client from disconnecting, but the heartbeat behaviour does seem wrong - there's 10 seconds between receiving the first heart beat from the server, and then I receive one every 5 seconds:

[2015-01-13 22:01:32,136] stomp.py     INFO     Sending frame ['STOMP', '\n', 'accept-version:1.1\n', 'heart-beat:10000,5000\n', 'host:datafeeds.networkrail.co.uk\n', 'login:ch...@pling.org.uk\n', 'passcode:f!ayo0mL#C#Ew!70ou5O\n', '\n', '\x00']
[2015-01-13 22:01:32,237] stomp.py     INFO     Sending frame ['SUBSCRIBE', '\n', 'ack:client-individual\n', 'destination:/topic/VSTP_ALL\n', 'id:test-vstp\n', '\n', '\x00']
[2015-01-13 22:01:32,237] stomp.py     DEBUG    listener <__main__.Listener object at 0x101c66790> has no method on_connected
[2015-01-13 22:01:32,238] stomp.py     INFO     Received frame: 'CONNECTED', headers={'session': 'ID:ec2netrailprodmaster1-37182-1421164873348-2:8446', 'version': '1.1', 'server': 'ActiveMQ/5.8.0', 'heart-beat': '5000,10000'}, body=''
[2015-01-13 22:01:42,195] stomp.py     DEBUG    listener <__main__.Listener object at 0x101c66790> has no method on_heartbeat
[2015-01-13 22:01:42,195] stomp.py     INFO     Received frame: 'heartbeat', headers={}, body=None
[2015-01-13 22:01:42,243] stomp.py     DEBUG    Sending a heartbeat message at 1421186502.24
[2015-01-13 22:01:42,243] stomp.py     INFO     Sending frame ['\n']
[2015-01-13 22:01:47,203] stomp.py     DEBUG    listener <__main__.Listener object at 0x101c66790> has no method on_heartbeat
[2015-01-13 22:01:47,203] stomp.py     INFO     Received frame: 'heartbeat', headers={}, body=None
[2015-01-13 22:01:52,210] stomp.py     DEBUG    listener <__main__.Listener object at 0x101c66790> has no method on_heartbeat
[2015-01-13 22:01:52,211] stomp.py     INFO     Received frame: 'heartbeat', headers={}, body=None
[2015-01-13 22:01:52,251] stomp.py     DEBUG    Sending a heartbeat message at 1421186512.25
[2015-01-13 22:01:52,251] stomp.py     INFO     Sending frame ['\n']
[2015-01-13 22:01:57,187] stomp.py     DEBUG    listener <__main__.Listener object at 0x101c66790> has no method on_heartbeat
[2015-01-13 22:01:57,187] stomp.py     INFO     Received frame: 'heartbeat', headers={}, body=None
[2015-01-13 22:02:02,195] stomp.py     DEBUG    listener <__main__.Listener object at 0x101c66790> has no method on_heartbeat
[2015-01-13 22:02:02,195] stomp.py     INFO     Received frame: 'heartbeat', headers={}, body=None
[2015-01-13 22:02:02,258] stomp.py     DEBUG    Sending a heartbeat message at 1421186522.26
[2015-01-13 22:02:02,259] stomp.py     INFO     Sending frame ['\n']
[2015-01-13 22:02:07,203] stomp.py     DEBUG    listener <__main__.Listener object at 0x101c66790> has no method on_heartbeat
[2015-01-13 22:02:07,203] stomp.py     INFO     Received frame: 'heartbeat', headers={}, body=None
[2015-01-13 22:02:12,215] stomp.py     DEBUG    listener <__main__.Listener object at 0x101c66790> has no method on_heartbeat
[2015-01-13 22:02:12,215] stomp.py     INFO     Received frame: 'heartbeat', headers={}, body=None
[2015-01-13 22:02:12,266] stomp.py     DEBUG    Sending a heartbeat message at 1421186532.27
[2015-01-13 22:02:12,266] stomp.py     INFO     Sending frame ['\n']
[2015-01-13 22:02:17,223] stomp.py     DEBUG    listener <__main__.Listener object at 0x101c66790> has no method on_heartbeat
[2015-01-13 22:02:17,223] stomp.py     INFO     Received frame: 'heartbeat', headers={}, body=None

Peter Hicks

unread,
Jan 13, 2015, 5:23:44 PM1/13/15
to Chris Northwood, openraildata-talk
Hi Chris

On 13/01/15 21:58, Chris Northwood wrote:
> Thanks Peter: https://gist.github.com/cnorthwood/323534c9df8230d6bbeb
> is an all-in-one script (requires you to install stomp.py). The script
> configures a debug logger which shows exactly what frames are
> sent/received. I wonder if the Ruby script you have can do similar,
> one difference I see is the 'send_fire' that the Ruby script appears
> to do, I'm not sure what that corresponds to?
I think send_fire is just a callback that the Stomp library on my side
calls when it sends a heartbeat.

I've run up your code here, and it fails as it did for you. I'm reading
through packet traces from both the Python and a Ruby client - I can't
see anything vastly different. It fails on both ActiveMQ 5.9.1 and
5.10.0 unless I set the heartbeat to 10000,5000.

My suspicion is that ActiveMQ maybe starts off slower than the Python
client can handle. If I set heatbeats to (8000,5000), it works. At
(7999,5000) or lower, it fails.

I am undecided as to what to do here - maybe set your heartbeats to at
least (8000,5000) whilst also filing a bug with the author of your Stomp
library to report its behaviour with ActiveMQ...?


Peter

Reply all
Reply to author
Forward
0 new messages