Web Sockets

Hi

I am working on a project that will interact with some software called ROS (Robot Operating System). One of the development challenges we have is as follows:

 

ROS uses web sockets... So one connect with ws://localhost:9090 to the web socket server.  It starts off as http, but then "upgrades" to web socket.  It then keeps open this "tunnel" for bi-directional communication..

 

I need something like a HTTP Outbound adapter, but the Web Socket version of it...

Does anyone have any experience in this area?

 

Nigel

Vote up!
Vote down!

Rating: 0

Comments: 4 Views: 131

Comments

Pinging web socket experts @Nikita Savchenko and @Fabian Haupt.

Also see Fabian's article about web sockets, HTH.

Vote up!
Vote down!

Rating: 0

I am not aware of any WS client implementation in COS.
Keep in mind that WS would mean a continuous connection, which doesn't really fit with the Operations model for Ensemble.

Vote up!
Vote down!

Rating: 0

2 answers

Answer

Hi Nigel!

I have been using %CSP.WebSocket class for my WebTerminal project. All you need to handle WebSocket connections is in this class. By mixing globals and/or interprocess communication you can achieve pretty much any result you need. There are plenty of resources in the Internet to get started with InterSystems WebSockets, but if you have any particular questions (which is not obvious from the post content), feel free to ask.

P.S. Oops, posted answer instead of comment.

Vote up!
Vote down!

Rating: 0

Nikita, he is also asking about cache as websocket CLIENT not as server.

Vote up!
Vote down!

Rating: 0

Missed this. I have never seen WS client implementations on COS neither.

Vote up!
Vote down!

Rating: 0

Answer

The Ensemble operation would definitely need a custom adapter written.

Probably wouldn't be that hard, just a bit time consuming getting all of the message frames working over TCP and handling fringe issues such as stale buffer data.

The only nag is that implementing this via one operation would be an anti pattern. Unsolicited ROS messages should really be entering Ensemble via a service.

However, there is a quick win that would solve this.

Create a small node process that would multiplex ROS web socket messages between an inbound HTTP service and an outbound HTTP operation.  ROS will think its talking to a socket client whilst Ensemble will thinks its talking to a pub sub over HTTP. Importantly you would get a bi-direction flow of messages in and out of Ensemble in the right directions.

Node has the battle tested libs to translate between the two. At tops probably 100 lines of node glue code to get this working. Leveraging on Ensembles standard HTTP adapters means this should all be stable out of the box.

 

Vote up!
Vote down!

Rating: 1

Log in to answer