Node.js Stomp Client

571 views
Skip to first unread message

Steve Macey

unread,
Nov 6, 2014, 10:55:44 AM11/6/14
to openrail...@googlegroups.com
Hi All,

I have done a bit of searching but I can't figure this out. I have used the example Node.js code to create a stomp client. I am registered, have an active account and am subscribed to the correct feed. Here is my code:

var prettyjson = require('prettyjson'),
    destination = '/topic/TRAIN_MVT_ALL_TOC',
    Stomp = require('stomp-client').StompClient,
    client = new Stomp('datafeeds.networkrail.co.uk', 61618, '******', '*******');

client.connect(function (sessionId) {
    console.log('Trying to connect...');
    client.subscribe(destination, function (body, headers) {
        console.log(prettyjson.render(JSON.parse(body)));
    });
});

However when I run this file through the terminal I get this result:

Error: connect ECONNREFUSED

    at errnoException (net.js:904:11)

    at Object.afterConnect [as oncomplete] (net.js:895:19)

I can't see where I am going wrong, can anyone help?

Thanks in advance.

Steve

Kevin Fullerton

unread,
Nov 6, 2014, 11:11:41 AM11/6/14
to Steve Macey, openrail...@googlegroups.com
I believe (I don't do any node.js) from my ruby poller that the datafeeds require Stomp v1.1 - assuming you're using https://www.npmjs.org/package/stomp-client that says it only supports Stomp v1.0 which may be why the connection isn't working (although ECONNREFUSED sounds more like it's not connecting at all rather than running an unsupported protocol version?)

A quick look at npm seems like https://www.npmjs.org/package/stompit _should_ support Stomp v1.1 so not sure if it's worth a quick test with that library instead?

Cheers

Kevin

--
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.
For more options, visit https://groups.google.com/d/optout.

Peter Hicks

unread,
Nov 6, 2014, 11:20:25 AM11/6/14
to Kevin Fullerton, Steve Macey, openrail...@googlegroups.com
Hi Kevin, Steve,

> On 6 Nov 2014, at 16:11, Kevin Fullerton <ke...@carshaft.com> wrote:
>
> I believe (I don't do any node.js) from my ruby poller that the datafeeds require Stomp v1.1 - assuming you're using https://www.npmjs.org/package/stomp-client that says it only supports Stomp v1.0 which may be why the connection isn't working (although ECONNREFUSED sounds more like it's not connecting at all rather than running an unsupported protocol version?)

ECONNREFUSED sounds much more like a TCP connection refused - I don’t think the feeds *need* Stomp 1.1, but if you want to use some features, you have to use it (durable subscriptions or heartbeats, I think).

Steve - can you telnet to datafeeds.networkrail.co.uk port 61618 from the machine you’re running the Node.js client? I’m wondering if you’re being blocked by a firewall on your side.


Peter

Steve Macey

unread,
Nov 6, 2014, 12:03:50 PM11/6/14
to openrail...@googlegroups.com
Thanks for the quick replies, I have tested the connection and it seems like it is being blocked by a firewall on our network. I'm going to give it another go when I get home. Will update with the result.

Steve Macey

unread,
Nov 6, 2014, 4:03:03 PM11/6/14
to openrail...@googlegroups.com
Got it working, now the fun starts...
Reply all
Reply to author
Forward
0 new messages