Connection confusion for PushPort STOMP

126 views
Skip to first unread message

ila...@redhat.com

unread,
May 17, 2016, 6:32:36 AM5/17/16
to A gathering place for the Open Rail Data community
I'm working on a simple JAVA Client to consume messages from the PushPort.

The DataFeed configuration page on my account gives a generic username and password and a specific queue - when connecting (to 61613, I assume) what is the combination of username/password/queue to provide?

Reason I ask is that I keep getting a network timeout when trying to connect - I've used the specific username/password and queue, the generic STOMP username, password and specific queue but no combination works.

Is the port correct? Is the port up (17-May 11:31)? What is the correct combination of information for connecting to the STOMP port?

Thanks in advance.

Peter Hicks

unread,
May 17, 2016, 6:36:19 AM5/17/16
to ila...@redhat.com, A gathering place for the Open Rail Data community
Hello

If you're working with Java, check out Apache Camel which has a Stomp component and also an ActiveMQ component which will be easier to wire up to your application than writing a client by hand.

Are you on a corporate network, or one where TCP port 61613 is firewalled?  You can check by opening a command prompt/shell and typing "telnet <hostname> 61613".  You should see something like this if it's successful:

Trying 54.77.164.226...
Escape character is '^]'.

If the connection is blocked by a firewall or similar, you'll see something like:

telnet: connect to address 54.77.164.226: Connection refused
telnet: connect to address 54.77.164.226: Host is down
telnet: connect to address 54.77.164.226: Connection timed out


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 an email to openrail...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ila...@redhat.com

unread,
May 17, 2016, 6:59:31 AM5/17/16
to A gathering place for the Open Rail Data community, ila...@redhat.com

I made somewhat of a newbie mistake and transcribed networkrail onto nationalrail....

Getting a connection now using my queue and the generic d3 usernames/passwords, but yet to receive messages. How does the PushPort work with the specific queue? I'm guessing it feeds that queue with the choice of messages you make at the configuration page at the feed site.

Peter Hicks

unread,
May 17, 2016, 7:02:40 AM5/17/16
to ila...@redhat.com, A gathering place for the Open Rail Data community
Hello

> On 17 May 2016, at 11:59, ila...@redhat.com wrote:
>
> Getting a connection now using my queue and the generic d3 usernames/passwords, but yet to receive messages. How does the PushPort work with the specific queue? I'm guessing it feeds that queue with the choice of messages you make at the configuration page at the feed site.

With a specific queue, you receive a combination of different types of messages according to what you’ve selected on the UI.

It’s similar to the Network Rail site using different topics, but because the data can be filtered on a finer method than just by TOC (e.g. you can filter by TIPLOC, message type, etc.), having thousands of topics makes no sense, and having per-user queues more sense.


Peter

ila...@redhat.com

unread,
May 17, 2016, 7:14:21 AM5/17/16
to A gathering place for the Open Rail Data community, ila...@redhat.com
I'm now getting a valid connection but no messages - I thought it was a five minute refresh on push. Can't quite see how to debug it if I'm getting a valid connection and no messages.

For information, here's the test class I'm using for the connection:

package org.uth.networkrail.tests;

import net.ser1.stomp.Client;
import net.ser1.stomp.Listener;
import org.uth.networkrail.listeners.NetworkRailListener;

/**
* Simple connection and message test.
* @author Ian 'Uther' Lawson
*/
public class NetworkRailConnectTest1
{
private static final String SERVER = "datafeeds.nationalrail.co.uk";
private static final int PORT = 61613;

public static void main( String[] args )
{
if( args.length != 3 )
{
System.out.println( "Usage: java NetworkRailConnectTest1 user password topic");
System.exit(0);
}

new NetworkRailConnectTest1( args[0], args[1], args[2]);
}

public NetworkRailConnectTest1( String username, String password, String topic )
{
try
{
long start = System.currentTimeMillis();
System.out.println( "[NRCT1] Connecting to datafeeds....");

Client client = new Client( SERVER, PORT, username, password );

if( client.isConnected())
{
long end = System.currentTimeMillis();

System.out.println( "[NRCT1] Connected to " + SERVER + ":" + PORT + " in " + (end-start) + "ms.");

System.out.println( "[NRCT1] Subscribing to " + topic );

Listener listener = new NetworkRailListener();
client.subscribe(topic, listener);

System.out.println( "[NRCT1] Listening on topic...");
}
else
{
System.out.println( "[NRCT1] Failed to connect.");
}
}
catch( Exception exc )
{
System.out.println( "Exception occurred: " + exc.toString());
}
}
}

And here's the listener:
package org.uth.networkrail.listeners;

import java.util.Map;
import net.ser1.stomp.Listener;
import org.uth.networkrail.utils.HumanReadableDate;

/**
* First test listener to read message from the Network Rail ActiveMQ topics.
* @author Ian 'Uther' Lawson
*/
public class NetworkRailListener implements Listener
{
@Override
public void message( Map Header, String body )
{
long now = System.currentTimeMillis();

System.out.println( "[" + HumanReadableDate.getDate(now) + "] received message.");
System.out.println( " Message size: " + body.length());
}
}

For parameters I use the generic d3 username and password and my specific queue.

All look right?

Peter Hicks

unread,
May 17, 2016, 7:16:59 AM5/17/16
to ila...@redhat.com, A gathering place for the Open Rail Data community
Check you’re subscribing to /queue/<UUID>, and also that your client.subscribe() call is succeeding. I’ve not use the the ser1 Stomp client, only Camel, but I’ve been tripped up in the past by other clients.

Also, log in to the UI and on the My Feeds page, make sure you have ‘All data types’ and ‘All TIPLOCs’ selected to start with, at least for testing.


Peter

ila...@redhat.com

unread,
May 17, 2016, 7:36:25 AM5/17/16
to A gathering place for the Open Rail Data community, ila...@redhat.com

Nice catch. Getting closer, using /queue/x gets me a connection and a single message back, but the message is not repeated and contains only:

[NRCT1] Connecting to datafeeds....
[NRCT1] Connected to datafeeds.nationalrail.co.uk:61613 in 269ms.
[NRCT1] Subscribing to /queue/myqueue
[NRCT1] Listening on topic...
[2016-05-17 12:29:23] received message.
Header: content-length 349
Header: expires 1463484807078
Header: destination /queue/myqueue
Header: message-id ID:EC2D3-PROD-DB-33579-1463361941701-14:1:2:1:148336009
Header: persistent true
Header: priority 0
Header: CacheHeaderFilterLevels 201605171983360,
Header: timestamp 1463484507086
Header: FilterHeaderLevel TRAINSTATUS,
Message: �

I'm wondering whether my account has been activated beyond just getting a connection yet...

Peter Hicks

unread,
May 17, 2016, 7:46:50 AM5/17/16
to ila...@redhat.com, A gathering place for the Open Rail Data community
> I'm wondering whether my account has been activated beyond just getting a connection yet…

If you disconnect and reconnect, do you get another message, i.e. are you just getting one message per connection?

You should be getting a big stream of data - >50 messages/sec! That message you have there is from 12:28:27 (the timestamp is in milliseconds since the UNIX epoch)


Peter
signature.asc

ila...@redhat.com

unread,
May 17, 2016, 8:02:37 AM5/17/16
to A gathering place for the Open Rail Data community, ila...@redhat.com
Odd thing is I just fired up and tried the Python STOMP client and there's tonnes of information, so the queue is active and producing information, the JAVA code is flawed somewhere.

Back to the drawing board - might just setup a Python service to pull down the information and store it and write a JAVA frontend for processing the post-Python installed stuff....

ila...@redhat.com

unread,
May 17, 2016, 8:35:17 AM5/17/16
to A gathering place for the Open Rail Data community, ila...@redhat.com
I think it is down to the fact that the STOMP library does not auto-acknowledge the message and I can't see a way (in Gozirra) of configuring it to do that.

What I am going to do is write a Python data-puller and store the data, then write a JAVA frontend for interpreting it rather than try and fix the STOMP side.

Reply all
Reply to author
Forward
0 new messages