Page 1 of 1
Interface Gateway Questions 21/04/2016 at 14:28 #81943 | |
Gwasanaethau
509 posts |
Hi all, I’ve been doing some experimenting with the Interface Gateway but am having some issues with generation/reception of messages. Are Gateway messages restricted to certain sims or can any loader sim now generate messages? I ask because Wireshark does not detect any activity on 127.0.0.1 even when a sim (so far I’ve only tried Wembley Suburban and Wembley Mail Line) has the interface activated. Setting up my own server on port 51515 in advance causes the sims to complain that it can’t “Open a TCP port for hosting the information gateway”. There is some activity on 127.0.0.1 when the loader is initially started, however; and running my own server/client on port 51515 results in Wireshark detecting activity too. I am currently testing this in Ubuntu with Wine, but testing in Windows 8.1 yielded identical results. Any thoughts? Mark (Gwasanaethau) Log in to reply |
Interface Gateway Questions 21/04/2016 at 14:41 #81944 | |
headshot119
4869 posts |
The interface gateway is tied into the core code, rather than being specific to a sim. I have a feeling you won't see anything on Wireshark unless you've successfully used a STOMP based client to subscribe to the data feed. If you want to view the messages you'd be better off using a STOMP client in any case, since some of the latest features have been added to the gateway the amount of messages generated is rather large, and it'd be difficult to make sense of them in Wireshark. (Or I find anyway) There's some fairly comprehensive documentation on the messages that you can receive out of the gateway on this Wiki page. The Wiki documentation is about three core code versions behind the latest release of the core code; myself and James haven't got round to adding the latest features into it yet. If you need some help with a STOMP client, I wrote a very basic example for the Wiki which is hosted on my Github page here. It's written in Python 3, and will print each message out to the console. When you get going with it, what you can do with the gateway is fairly powerful. Watch this space... "Passengers for New Lane, should be seated in the rear coach of the train " - Opinions are my own and not those of my employer Log in to reply The following user said thank you: Gwasanaethau |
Interface Gateway Questions 21/04/2016 at 15:35 #81945 | |
Gwasanaethau
509 posts |
Thanks for that explanation. Yeah, I had already discovered the wiki page and had a look at your python script. My python is non-existant, but I got the idea what the script was doing. I couldn’t run it because I don’t know what I am doing when it comes to python modules, but I did manage to write a Java programme that does the same thing as yours (thanks!) based on StompJ. I can now see the handshakes between the sim and my client; or rather the error messages as my client is abysmal, but at least I am getting somewhere now. It didn’t even occur to me that no messages would be sent from the sim unless something was connected to it. Ack (or should that be SYN/ACK? :silly: ), I’m learning! Unfortunately both StompJ and Gozirra Java STOMP libraries only support version 1.0, and the sim is not quiet about telling me I need a version 1.1 aware client! That’s the next step. Gonna explore a bit more for a while. I am really doing this for my own intrigue more than anything else. I guess you could say I am a hobby-coder, just like a backyard-shed-tinkerer but with code. Really fascinated by this! Thanks for your direction…hopefully I’ll get somewhere soon! Log in to reply |
Interface Gateway Questions 21/04/2016 at 16:31 #81947 | |
headshot119
4869 posts |
If you need any more help don't be afraid to ask! I've dabbled in STOMP clients in a few languages. Java is the only one I haven't tried. I'd be interested to know if anyone else has tried doing anything with the gateway. There's some quite interesting things you can do with it. "Passengers for New Lane, should be seated in the rear coach of the train " - Opinions are my own and not those of my employer Log in to reply The following user said thank you: Gwasanaethau |
Interface Gateway Questions 21/04/2016 at 16:34 #81948 | |
GeoffM
6377 posts |
Quick note: you should not be hosting a server on the same port as SimSig. You're the client in this scenario.
SimSig Boss Log in to reply The following user said thank you: Gwasanaethau |
Interface Gateway Questions 22/04/2016 at 01:05 #81954 | |
Gwasanaethau
509 posts |
" said:Quick note: you should not be hosting a server on the same port as SimSig. You're the client in this scenario. Thanks Geoff. This was more to test that I didn’t have firewalls/internal gubbins preventing messages being transmitted. Once SimSig complained that the was a server already bound to the port I knew internals weren’t the issue, and SimSig was indeed working fine. Bit brutal, I know… :blush: @headshot: I’ve ended up writing a complete Java STOMP client from scratch. Am I mad or wha’? :yikes:! Thanks for your assistance. I’ll keep yiz up-to-date on how it goes. One quick question before I go (more of a confirmation than anything else): Does the SimSig server accept ‘STOMP’ commands as well as ‘CONNECT’ or is it just ‘CONNECT’? Log in to reply |
Interface Gateway Questions 22/04/2016 at 15:47 #81963 | |
GeoffM
6377 posts |
" said:@headshot: I’ve ended up writing a complete Java STOMP client from scratch. Am I mad or wha’? :yikes:!I had to write the server end from scratch in Delphi so ! " said: I’ll keep yiz up-to-date on how it goes.Please do - as far as I know, it's only really Karl's Kronies :silly: that have tested it in any great detail. " said: One quick question before I go (more of a confirmation than anything else): Does the SimSig server accept ‘STOMP’ commands as well as ‘CONNECT’ or is it just ‘CONNECT’?The verbs it currently handles are as follows:
So far there's been no need for the 3-4 other verbs but I'll consider adding them if a case can be made for them. SimSig Boss Log in to reply The following user said thank you: Gwasanaethau |
Interface Gateway Questions 22/04/2016 at 17:42 #81964 | |
headshot119
4869 posts |
" said:" said:Sounds like the name of a terrible band!!!@headshot: I’ve ended up writing a complete Java STOMP client from scratch. Am I mad or wha’? :yikes:!I had to write the server end from scratch in Delphi so ! I've spent a few minutes updating the Wiki page to take into account some of the new features that have been added to the gateway, and corrected some things that have changed since they where first introduced. "Passengers for New Lane, should be seated in the rear coach of the train " - Opinions are my own and not those of my employer Log in to reply The following user said thank you: Gwasanaethau |
Interface Gateway Questions 22/04/2016 at 21:39 #81969 | |
Gwasanaethau
509 posts |
Hahaha, Karl’s Kronies! I love it! :laugh: Thanks for all the info, guys. I was wondering if I had to deal with the entire protocol…thanks for the heads-up! Progress has been a little slow today with me trying to deal with I/O and Socket exceptions within the Java internals rather than actually parsing and dealing with STOMP messages, but it’s been fun nevertheless! Gonna dive in for a bit more for the next few hours methinks! Log in to reply |
Interface Gateway Questions 22/04/2016 at 21:57 #81970 | |
pedroathome
916 posts |
" said:" said:Just because some of us may have a physical panel connected to SimSig to display appropriate outputs B) :whistle:Please do - as far as I know, it's only really Karl's Kronies :silly: that have tested it in any great detail. On a side not Gwasanaethau, I started off working from the examples given for the NR data feeds, a C# example can be found here. http://nrodwiki.rockshore.net/index.php/C_Sharp_Examples Just leave the user name and password as blank, the IP is the IP of the sim you're connecting to, and port is again, the port of the sim you're connecting to. I'm sure that you've worked this out already however. James Last edited: 22/04/2016 at 21:59 by pedroathome Log in to reply |
Interface Gateway Questions 22/04/2016 at 23:25 #81971 | |
GeoffM
6377 posts |
STOMP is an incredibly simple protocol so yes, battling exceptions aside, it shouldn't take long to handle the protocol if not the actual message content. This is probably one reason why NR use it, and in turn, SimSig with some of the messages as identical as they can be to the NR ones.
SimSig Boss Log in to reply The following users said thank you: Gwasanaethau, BarryM |
Interface Gateway Questions 23/04/2016 at 07:01 #81972 | |
Gwasanaethau
509 posts |
Right! I now have a client that will connect to the server, subscribe, listen to messages, unsubscribe, disconnect and close. It also closes gracefully when an error is received. It is by no means robust, but I have the framework in place to actually get stuck in with parsing the messages now! :woohoo: Thanks again! Whilst testing, though, I’ve noticed a couple of things: - The server will still send messages even if UNSUBSCRIBE is sent to it, and it doesn’t return a RECEIPT frame even if a receipt header is added to the UNSUBSCRIBE frame; - The server REALLY dislikes the DISCONNECT frame, and will issue an access violation every time it receives one (it will still send a RECEIPT frame, though). I have attached a capture of the message in case you wanted to look at it. I’m excited to get stuck into parsing the messages now! Yey! B) - Mark Post has attachments. Log in to view them. Log in to reply |
Interface Gateway Questions 23/04/2016 at 10:44 #81973 | |
pedroathome
916 posts |
" said:Right! I now have a client that will connect to the server, subscribe, listen to messages, unsubscribe, disconnect and close. It also closes gracefully when an error is received. It is by no means robust, but I have the framework in place to actually get stuck in with parsing the messages now! :woohoo: Thanks again!I have had something like the error which you describe, but using C# (Can you confirm the language you're using?). I found that if I was running it as a console application there was no issues what so ever, however, running it as a windows application, this error came up every time I ran the program with no data being received I found this with the NR data feeds as well so suspect that there is something in the way mine was compiled, rather than having anything to do with SimSig (with the exception of getting that error message thorough SimSig). On a side note, I while again I don't know what language you're using, I'll happy share some of my C# code with you to possibly help you get an idea of what I done, just don't ask me to explain it. James Log in to reply |
Interface Gateway Questions 23/04/2016 at 20:09 #81977 | |
Gwasanaethau
509 posts |
" said:…I am using Java. It could well be a malformed STOMP frame in my case, as I’m not 100% certain what I’m doing, but I think I have adhered to the specs. Besides, SimSig doesn’t return an ERROR frame, so maybe it’s not. I’m still playing with it at the moment. I haven’t tried the NR servers yet. My programme is still under testing so I’m trying to keep it ‘in the lab’, so to speak. In any case, I doubt the language would matter as STOMP is the protocol the two hosts are using to communicate with each other. Thanks for the offer of your code, James, that is really very good of you. Part of this exercise is for my own tinkering fun, so I’m gonna try and see how far I can get myself. Have no fear, though; if I get brutally stuck I’ll come knocking on your door for directions! ;) - Mark Log in to reply |
Interface Gateway Questions 27/04/2016 at 23:57 #82010 | |
Gwasanaethau
509 posts |
I promised to keep you all updated on my progress: I now have a STOMP client interface that can (in theory) be used to interface with any STOMP server. I have then build a SimSig specific client that integrates with the STOMP client to receive and parse the JSON messages. I have tested it with a relatively simple programme that prints the colours of the signals in the Lancing sim to the CLI. Now, I’ve just got to remember what it was I wanted to do with this stuff! :doh Thanks all for your help and guidance with this. It’s been a fun old trip! – Mark Log in to reply The following user said thank you: DonRiver |
Interface Gateway Questions 28/04/2016 at 12:38 #82012 | |
pedroathome
916 posts |
" said:I promised to keep you all updated on my progress: I now have a STOMP client interface that can (in theory) be used to interface with any STOMP server. I have then build a SimSig specific client that integrates with the STOMP client to receive and parse the JSON messages. I have tested it with a relatively simple programme that prints the colours of the signals in the Lancing sim to the CLI. Now, I’ve just got to remember what it was I wanted to do with this stuff! :dohThe interface gateway is an interesting part to play around with. For me, it was learning a new programming language, (well I call it new, C to C#, different enough for me). Out of interest, what is your intentions on what you're hoping to end up doing with the gateway? I know I have posted this before, but this was one of my first attempts https://www.youtube.com/watch?v=Q0vUHdFt7-I James Last edited: 28/04/2016 at 12:39 by pedroathome Log in to reply |
Interface Gateway Questions 28/04/2016 at 15:09 #82014 | |
Gwasanaethau
509 posts |
That video is what prompted me to start all this in the first place! B) I saw it a while ago and thought about what I could do with the messages, but didn’t really get beyond thoughts. As I was playing Wembley Main Line last week, I remembered that video and wondered again what I could do with the feeds. As of now, I don’t really know what I could do with them. My creativity isn’t exactly fantastic! I was initially thinking of simulating a platform announcer for Euston or something like that (using espeak), but I realise I’d need to extract data from the WTT in order to do that. The cogs are still turning… ;) Gotta say – I’m in awe. I’ve tried C a few times. Boy is it hard! :unsure: – Mark Log in to reply |
Interface Gateway Questions 29/04/2016 at 15:09 #82041 | |
pedroathome
916 posts |
Apologies for what I have got you into on this. Although I personally haven't done much with the gateway for a week or two, other parts of project are taking place. I will just add though I know quite a few bits have changed in the data feeds since I first played around with them. James Log in to reply |
Interface Gateway Questions 29/04/2016 at 20:00 #82049 | |
Gwasanaethau
509 posts |
" said:Apologies for what I have got you into on this. Haha, no bother! I’ve been looking into the actual NR feeds and they look really complex. I *might* do something with those at some point, but for the moment I’m going to stick to the SimSig feeds. My thoughts for a first project are some airport-style ‘on approach’/‘arrived‘/‘departed’ screens. I’ll start off small: maybe Lancing, and then graduate to something larger (Wembley Suburban, possibly). Entry-level stuff for the moment. – Mark Log in to reply |
Interface Gateway Questions 29/04/2016 at 20:36 #82050 | |
Finger
220 posts |
Honestly, why don't you start with serious business like KX? That way it would make more sense. Also, there's nothing really hard about it.
Log in to reply |
Interface Gateway Questions 29/04/2016 at 20:58 #82055 | |
pedroathome
916 posts |
" said:Honestly, why don't you start with serious business like KX? That way it would make more sense. Also, there's nothing really hard about it.From what I have found, and I started on a small sim, however, once the basics are worked out, I could to at least a TT map for a sim in no time. My current project with the interface gateway is taking much longer and a lot more frustration indicating routes etc. James Log in to reply |
Interface Gateway Questions 02/05/2016 at 17:36 #82107 | |
Gwasanaethau
509 posts |
" said:Honestly, why don't you start with serious business like KX? That way it would make more sense. Also, there's nothing really hard about it. I’d rather start on a small one and get that running properly, and then progress to a larger one. It might be easy to get it up and running, but there’s a lot of parsing of messages going on. Keeping track of it all without the code becoming a sprawling mess is also time-consuming. Additionally, I am building a GUI to go with it, which takes a little bit of time to get up and running (not to mention life getting in the way too). But have no fear, I am eager to move on and up to larger sims once I have this one sorted! Log in to reply |