ProXR Relay Board Best Practices

I have a web application that fires relays to a turnstile when guest fill out visit details. Currently the code is written to make a web request which creates a socket, fires the relay, then closes the socket. Peak hours are only during the morning and afternoon where close to 500 visits can occur.

We have noticed the application getting hung up once in a while. I chose to open and close sockets since most of the time they would be idle, but what would you recommend is the best practice for connecting to the relay board? Should I open a single socket and keep it open as long as possible? Could opening and closing sockets cause problems with that many visits? Not sure that amount of request would cause issues. Please advise.

Thanks!

If you’re going to make rapid fire or simultaneous requests to a single relay board (I’m assuming you have a single relay board for multiple turnstiles) I would recommend building a FIFO command buffer. Basically an array of commands that need to go out. When a command needs to be sent it gets added to the end of the buffer. Then add a thread that handles the socket and has access to the buffer. It will be in charge of sending that command and, once the 85 response comes back, removing that command from the buffer to move onto the next one.

Opening and closing the socket each time is the easy way to make the Ethernet reliable. Leaving the socket open isn’t an issue 99% of the time, but it can lead to a total outage if there is an ungraceful closing of the socket on either end. This is a glitch that can happen where one side or the other believes the socket is still open when in fact it is closed on the other end. You can solve this issue by setting a timeout on the Ethernet Module (through the web UI). In the software you will also need to send a heartbeat to the module if a communication hasn’t gone out in x amount of seconds. I’d just send a 254 33 (check for two way communications command).

Thanks for the quick reply Jacob.Your assumption is correct about having a single board for many turnstiles. A FIFO command buffer sounds like a good idea that would make communication much more scale-able. Will look into implementing that. Thanks again for the feedback!