There seem to be some server issues today, I keep getting disconnected and sometimes can't even connect at all.
IDestination destination = session.GetDestination("topic://" + "DATA_FEED");
IMessageConsumer consumer = session.CreateConsumer(destination);
Hi I'm receiving an error on the line IMessageConsumer with
The connection is already closed!
any ideas?
everything looks fine with the code you posted, nothing jumps out on me. The only thing I can suggest is double check your username/password are correct, and you have enabled the feed you are trying to connect to.
For reference, there is a code sample located at http://wiki.openraildata.info/index.php/C-Sharp although it's probably the same one you are using.
Poggs, after reading through the first couple of pages of the thread I've resolved the issue, although I can receive the odd message from the feed now with the PHP receiver, it seems no where near as reliable as my Ruby implementation, and likes to timeout all over the shop.
I might have to look into something in .NET to achieve what I want.
I'm having a few problems using the data feeds via Network Rail. I have subscribed to a few feeds, but how do I get them?
I'm having a few problems using the data feeds via Network Rail. I have subscribed to a few feeds, but how do I get them?
Stomp enabled
API version 1.0.5
SSL Support enabled
Directive Local Value Master Value
stomp.default_broker tcp://localhost:61613 tcp://localhost:61613
stomp.default_connection_timeout_sec 2 2
stomp.default_connection_timeout_usec 0 0
stomp.default_read_timeout_sec 2 2
stomp.default_read_timeout_usec 0 0
<?php
// Network Rail Stomp Handler example by ian13
$server = "tcp://datafeeds.networkrail.co.uk:61618";
$user = "username";
$password = "password";
$channel = "TRAIN_MVT_ALL_TOC";
$con = new Stomp($server, $user, $password);
if (!$con) {
die('Connection failed: ' . stomp_connect_error());
}
$con->subscribe("/topic/" . $channel);
while($con){
if ($con->hasFrame()){
$msg = $con->readFrame();
foreach (json_decode($msg->body) as $event) {
// do stuff with $event here
}
$con->ack($msg);
}
}
die('Connection lost: ' . time());
?>
That is correct, there is no need to install ActiveMQ.If STOMP is doing the reading from the NR feed, do I need to also install ActiveMQ on the server. I was browing the wiki and it sems to indicate this is not required.
It's your email address and the same password you use for the website.Also, I see when I login I have a security token.. i assume the user name and password required in the example are my email address for the username and the security token for the password?
That is correct, there is no need to install ActiveMQ.
It's your email address and the same password you use for the website.
I initially thought that you just wanted to use STOMP to connect your server to the feeds but having just re-read your post, you say you have installed STOMP on the server and are expecting that to handle the messages. STOMP is a protocol and not something you install so what exactly have you actually installed?OK, so I put my user name and password in... now it takes a little longer but ultimatly STILL gives Error 500!
I initially thought that you just wanted to use STOMP to connect your server to the feeds but having just re-read your post, you say you have installed STOMP on the server and are expecting that to handle the messages. STOMP is a protocol and not something you install so what exactly have you actually installed?
<?php
/* connection */
$link = stomp_connect('tcp://datafeeds.networkrail.co.uk:61618','myusername', 'mypassword');
/* check connection */
if (!$link) {
die('Connection failed: ' . stomp_connect_error());
} else {
echo 'Connected';
}
/* close connection */
stomp_close($link);
?>
What code are you using to subscribe?
<?php
$server = "tcp://datafeeds.networkrail.co.uk:61618";
$user = "myemail";
$password = "mypassword";
$channel = "RTPPM_ALL";
$con = new Stomp($server, $user, $password);
if (!$con) {
die('Connection failed: ' . stomp_connect_error());
}
$con->subscribe("/topic/" . $channel);
// receive a message from the queue
$msg = $con->readFrame();
// do what you want with the message
if ( $msg != null) {
echo "Received message with body '$msg->body'\n";
// mark the message as received in the queue
$con->ack($msg);
} else {
echo "Failed to receive a message\n";
}
die('Connection lost: ' . time());
?>
<?php
$server = "tcp://datafeeds.networkrail.co.uk:61618";
$user = "myusername";
$password = "mypassword";
$channel = "RTPPM_ALL";
$con = new Stomp($server, $user, $password);
if (!$con) {
die('Connection failed: ' . stomp_connect_error());
}
$con->subscribe("/topic/" . $channel);
// receive a message from the queue
$msg = $con->readFrame();
// do what you want with the message
if ( $msg != null) {
listPosts($msg->body);
$con->ack($msg);
} else {
echo "Failed to receive a message\n";
}
die('Connection lost: ' . time());
?>
As the attempt never seems to be for very long, so I am thinking the request is timing out too fast.
For testing purposes, yeah I am running it through a browser
Try *not* running it through a browser - see http://php.net/manual/en/features.commandline.php.
There are all sorts of problems you might get with running a long-lived daemon under Apache, such as the server buffering data before sending it to your browser (so you think you've not received messages) that will only confuse matters.
Try *not* running it through a browser - see http://php.net/manual/en/features.commandline.php.
There are all sorts of problems you might get with running a long-lived daemon under Apache, such as the server buffering data before sending it to your browser (so you think you've not received messages) that will only confuse matters.