Automatic disconnect using STOMP in Python3

297 views
Skip to first unread message

Christos Ioannou

unread,
Jun 27, 2019, 8:44:55 AM6/27/19
to A gathering place for the Open Rail Data community
Hello.

I am using the example client given in https://github.com/openraildata/stomp-client-python.
I can successfully connect to the Status Messages Topic using the code snippet below.

connection.subscribe(destination='/topic/darwin.status',
 id
='1',
 ack
='auto',
 headers
=subscribe_header)

With this, I can stay connected and receive heartbeat messages periodically:

Connecting to darwin-dist-44ae45.nationalrail.co.uk
Received a heartbeat


Changing the destination to subscribe to the Live Feed Topic raises the issue. It is the same issue mentioned here: https://groups.google.com/forum/#!searchin/openraildata-talk/python$20v3%7Csort:date/openraildata-talk/X8pudhCqB40/ciE1tWV_AAAJ


 connection.subscribe(destination='/topic/darwin.pushport-v16',
 id
='1',
 ack
='auto',
 headers
=subscribe_header)


Connecting to darwin-dist-44ae45.nationalrail.co.uk
Disconnected waiting 15 seconds before exiting

I haven't changed anything else in the code other than entering my credentials given in 'My Feeds' in opendata.nationalrail.co.uk.

Note: In the README file, it says to set HOSTNAME = Live Feed Topic where as it should be set to Messaging host



Peter Hicks

unread,
Jun 27, 2019, 8:48:58 AM6/27/19
to Christos Ioannou, A gathering place for the Open Rail Data community
Hi Christos

I've just merged a pull request which made a couple of fixes/changes to the code - could you do a 'git update' on your side and see if it fixes the issue?  If not, I'll run up a copy of Python here and try to reproduce what you're seeing.


Peter


--
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-t...@googlegroups.com.
To post to this group, send email to openrail...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/openraildata-talk/b5fdc3fc-bb80-40c1-bf9a-0e2546163841%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


OpenTrainTimes Ltd. registered in England and Wales, company no. 09504022.
Registered office: 13a Davenant Road, Upper Holloway, London N19 3NW

Christos Ioannou

unread,
Jun 27, 2019, 8:59:24 AM6/27/19
to A gathering place for the Open Rail Data community
Hi Peter,

Thank you for the quick reply. This seems to have fixed the issue.

Christos
To unsubscribe from this group and stop receiving emails from it, send an email to openrail...@googlegroups.com.

Paul Hernandez

unread,
Mar 3, 2020, 2:26:13 PM3/3/20
to A gathering place for the Open Rail Data community
Hi everyone, 

I am facing a similar error as described by Christos, 

my client get disconnected every 60 to 90 seconds and does not reconnect automatically. 

Any hint? It would be appreciated :)

Best, 
Paul

Peter Hicks

unread,
Mar 3, 2020, 2:28:19 PM3/3/20
to A gathering place for the Open Rail Data community
Hi Paul

On Tue, 3 Mar 2020 at 19:26, Paul Hernandez <paul.p...@gmail.com> wrote:

I am facing a similar error as described by Christos, 

my client get disconnected every 60 to 90 seconds and does not reconnect automatically. 

Any hint? It would be appreciated :)

Do you always get disconnected after 60-90 seconds?  If you restart the script, can you reconnect immediately?


Peter 

Paul Hernandez

unread,
Mar 3, 2020, 2:41:26 PM3/3/20
to A gathering place for the Open Rail Data community
Hi Peter, 

sometimes I got 3 or 4 heartbeats before disconnecting. I am testing the code with Visual Studio Code. It happens from time to time that the client is not able to establish a connection because the server thinks it is still connected.

The client get the messages and send them to an azure event hub.

Best, 
Paul

Peter Hicks

unread,
Mar 3, 2020, 3:11:40 PM3/3/20
to A gathering place for the Open Rail Data community
Hi Paul

You're using VSCode - just to check, are you using Python?  If you use the code at https://github.com/openraildata/stomp-client-python (and it's been updated recently), do you get the same issue?


Peter


--
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-t...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/openraildata-talk/25f21011-69fd-4ba6-9f3f-783f755bea42%40googlegroups.com.

Paul Hernandez

unread,
Mar 4, 2020, 8:55:05 AM3/4/20
to A gathering place for the Open Rail Data community
Hi Peter, 

I pulled the last version of the stom-client-python you referenced and included it into my VSCode project.

Also installed the required python modules as per READ.md

The situation is basically the same:

stomp-py-disconnect.JPG


I may need to understand the code a bit better.

Thanks and kind regards, 

Paul



Am Dienstag, 3. März 2020 21:11:40 UTC+1 schrieb Peter Hicks:
Hi Paul

You're using VSCode - just to check, are you using Python?  If you use the code at https://github.com/openraildata/stomp-client-python (and it's been updated recently), do you get the same issue?


Peter


On Tue, 3 Mar 2020 at 19:41, Paul Hernandez <paul.p...@gmail.com> wrote:
Hi Peter, 

sometimes I got 3 or 4 heartbeats before disconnecting. I am testing the code with Visual Studio Code. It happens from time to time that the client is not able to establish a connection because the server thinks it is still connected.

The client get the messages and send them to an azure event hub.

Best, 
Paul

Am Dienstag, 3. März 2020 20:28:19 UTC+1 schrieb Peter Hicks:
Hi Paul

On Tue, 3 Mar 2020 at 19:26, Paul Hernandez <paul.p...@gmail.com> wrote:

I am facing a similar error as described by Christos, 

my client get disconnected every 60 to 90 seconds and does not reconnect automatically. 

Any hint? It would be appreciated :)

Do you always get disconnected after 60-90 seconds?  If you restart the script, can you reconnect immediately?


Peter 


OpenTrainTimes Ltd. registered in England and Wales, company no. 09504022.
Registered office: 13a Davenant Road, Upper Holloway, London N19 3NW

--
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 openrail...@googlegroups.com.

Peter Hicks

unread,
Mar 4, 2020, 9:06:11 AM3/4/20
to A gathering place for the Open Rail Data community
Hi Paul

Log in to https://opendata.nationalrail.co.uk/ and check that you have "Darwin" checked under "Subscribe to feeds".  It doesn't look like you're receiving any messages!

Also, under 'My Feeds', what is the messaging host?  Does it start with darwin-dist?


Peter


To unsubscribe from this group and stop receiving emails from it, send an email to openraildata-t...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/openraildata-talk/a672f1f9-1264-4cbc-8eb9-64f0339210ab%40googlegroups.com.

Paul Hernandez

unread,
Mar 4, 2020, 10:46:11 AM3/4/20
to A gathering place for the Open Rail Data community
Hi Peter, 

many thanks again! :-)

I was testing my subscription to the "Knowledgebase (KB) Real Time Incidents" and not to the Darwin feed.

I tried with Darwin and I am able to get at least one message but the client got disconnected too:

Darwin disconnect.JPG


Hier the topic info from my feeds page:


Darwin feed info.JPG

I am behind a corporate firewall using a VPN Tunnel. I think this shouldn't be a problem because I configured the proxy settings accordingly but I will give it a try with my home network.


Best regards, 
Paul

Am Donnerstag, 27. Juni 2019 14:44:55 UTC+2 schrieb Christos Ioannou:
Reply all
Reply to author
Forward
0 new messages