Python and stomp

415 views
Skip to first unread message

Alex Dudiak

unread,
Jan 29, 2013, 2:44:38 PM1/29/13
to openrail...@googlegroups.com
Does anybody have any experience of using stomp with python. I can connect and get data through c#, but when I try the same test through python (using the stomp.py library 'http://code.google.com/p/stomppy/'). I get the error 'User ......... is not authorized to read from: queue://topic://TRAIN_MVT_ALL_TOC'.

Any pointers greatly appreciated 

Regards

Alex

Automsoft ®
Understand information – predict outcomes

EMEANorth AmericaWeb: http://www.automsoft.com
Dublin, IrelandPrinceton, NJEmail: in...@automsoft.com
Tel + 353 1 449 1100Tel +1 609 514 5145Support: sup...@automsoft.com

Process Data Historian & Optimization Solutions for:
Life Sciences / Smart Grid / Power & Utilities / Renewable Energy / Oil & Gas / Manufacturing / Maritime

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient, please note that any review, dissemination, disclosure, alteration, printing, circulation or transmission of this e-mail and / or any file or attachment transmitted with it, is prohibited. If you have received this e-mail or any file or attachment transmitted with it in error please notify Automsoft and delete all copies of this e-mail from your computer system(s).

This footnote also confirms that this email message has been swept for the presence of computer viruses.

Peter Hicks

unread,
Jan 29, 2013, 2:46:08 PM1/29/13
to Alex Dudiak, openrail...@googlegroups.com
Hi Alex

On 29 Jan 2013, at 19:44, Alex Dudiak <alex....@automsoft.com> wrote:

> Does anybody have any experience of using stomp with python. I can connect and get data through c#, but when I try the same test through python (using the stomp.py library 'http://code.google.com/p/stomppy/'). I get the error 'User ......... is not authorized to read from: queue://topic://TRAIN_MVT_ALL_TOC'.

You need to specify /topic/TRAIN_MVT_ALL_TOC rather than queue://topic:// - that's possibly where it's failing.


Peter


Alex Dudiak

unread,
Jan 29, 2013, 3:19:09 PM1/29/13
to openrail...@googlegroups.com, Alex Dudiak
Much appreciated Peter, the extra slash was the culprit. Code now happily returning loads of lovely json, now the fun of making sense of it all.

Regards

Alex

Rob Bainbridge

unread,
Jul 3, 2013, 8:03:03 AM7/3/13
to openrail...@googlegroups.com, Alex Dudiak
Hi Alex, Peter, 

I stumbled across this thread when trying to access the Network Rail data feeds using python. I have tried manipulating the "topic" string, as suggested above, but I still see the following error:

stompy.frame.BrokerErrorResponse: Broker Returned Error: java.lang.SecurityException: User XXX is not authorized to read from: topic://TRAIN_MVT_ALL_TOC

Example code to reproduce the behaviour is found below. I know it's not a question of subscription because when I subscribe to a stream directly via the website, I can connect without any problems and pull the feed. So presumably it's a problem related to how I'm using the STOMP client. 

Any help is appreciated. 

Cheers,
rob


from stompy.simple import Client
feed = Client(host='datafeeds.networkrail.co.uk', port=61618)
feed.connect(username='my_email',password='my_passwd')
feed.subscribe('/topic/TRAIN_MVT_ALL_TOC')
print feed.get()
feed.unsubscribe('/topic/TRAIN_MVT_ALL_TOC')
feed.disconnect()


Peter Hicks

unread,
Jul 3, 2013, 10:52:12 AM7/3/13
to openrail...@googlegroups.com
On 03/07/13 13:03, Rob Bainbridge wrote:
> I stumbled across this thread when trying to access the Network Rail
> data feeds using python. I have tried manipulating the "topic" string,
> as suggested above, but I still see the following error:
>
> stompy.frame.BrokerErrorResponse: Broker Returned Error:
> java.lang.SecurityException: User XXX is not authorized to read from:
> topic://TRAIN_MVT_ALL_TOC
>
> Example code to reproduce the behaviour is found below. I know it's
> not a question of subscription because when I subscribe to a stream
> directly via the website, I can connect without any problems and pull
> the feed. So presumably it's a problem related to how I'm using the
> STOMP client.
>
Have you tried just /topic/TRAIN_MVT_ALL_TOC?


Peter

Rob Bainbridge

unread,
Jul 3, 2013, 11:02:02 AM7/3/13
to openrail...@googlegroups.com
Hi Peter,

thanks for your reply. This is indeed what I used:

feed.subscribe('/topic/TRAIN_MVT_ALL_TOC')

The error message reformats this to:

User XXX is not authorized to read from: topic://TRAIN_MVT_ALL_TOC

Various trials reveal similar messages. For instance, if I remove the leading "/" then I see this:

User XXX is not authorized to read from: queue://topic/TRAIN_MVT_ALL_TOC

If I subscribe to a feed via the website, the error message disappears and I receive the feed normally. 


Jonathon Hurley

unread,
Jul 3, 2013, 11:42:01 AM7/3/13
to Rob Bainbridge, openrail...@googlegroups.com
> If I subscribe to a feed via the website, the error message disappears and I receive the feed normally.
>

Forgive me if I've missed the point, but isn't that the expected
behaviour? To be able to access a feed you need to subscribe to it
through the website first.

Regards

Jonathon

Peter Hicks

unread,
Jul 3, 2013, 12:28:23 PM7/3/13
to openrail...@googlegroups.com
Correct - you need to subscribe to a feed before you can read from it -
it's so we can see who's using which feed, which the most popular ones
are, etc.


Peter

Rob Bainbridge

unread,
Jul 3, 2013, 12:32:46 PM7/3/13
to openrail...@googlegroups.com
Ah, my mistake - apologies for the noise. 

(I understood the subscribe method in the STOMP API to perform this action.)

Thanks for the prompt feedback. 

Cheers,
rob
Reply all
Reply to author
Forward
0 new messages