Web Sockets


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?



  • 0
  • 0
  • 528
  • 4
  • 2


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.

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

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

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.



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.