WSS Data Feed into Losant Workflow/Data

Would like to incorporate WSS fed data into Losant workflow. It is for a voltage meter which is continually sending the following payload;

{
“payload”: {
“voltage”: [
121.82426452636719,
122.04183197021484
],
“frame”: 9327510,
“devices”: [

I have tried to use MQTT integration as recommended elsewhere in forums but no joy. What is the recommended means of incorporating this data into Losant?

I don’t have a great answer here; we have a websocket integration feature in our backlog, where the platform would act as a client and initiate a request, and you could then fire workflows on received messages and publish back over the connection. I will add your +1 to that request.

I’m afraid you’d have to bring in a third-party service to act as the WSS client and then forward payloads over to Losant via HTTP requests to a webhook or some other means. If you are doing this on the edge, you have additional options.

1 Like

I can do this on the edge - please advise :slight_smile:

There are a few ways to accomplish this, but depends on which direction the websocket connection is going. Is your source of websocket data a server and you require a websocket client to connect to that server? Or is the source of data a websocket client that requires a server to connect to?

Websocket client - e.g. I am able to see the data using Postman WSS (beta)

Understood. I’ve seen two modes for websocket APIs like this. For yours, do you make a connection and data just begins flowing? Or is it transactional, where you make a connection and the client must send some request to the server and the server will reply with data?

Data begins flowing no request needed.

I recommend running websocat to forward websocket packets to the GEA’s UDP server.

For example, if your websocket server is running on locahost:7777 and the GEA is listening on UDP port 3456, the following command will connect to your websocket server and forward every packet to the GEA:

websocat --text ws://localhost:7777 udp:127.0.0.1:3456

Websocat is supported on all major CPU architectures and Linux distros. Here’s a guide on installing websocat on a Raspberry Pi. I used a Raspberry Pi 3 to test this implementation.

When running the GEA, you’ll need to expose the UDP port by adding the following to your Docker run command:

-p 3456:3456/udp

You’ll then need to add a UDP Trigger to your edge workflow with the same port as you exposed above.

Now whenever websocat receives a websocket packet, it will forward it to UDP and trigger your workflow.

Depending on your Linux distro, you’ll likely want to launch the websocat command as a service/daemon (systemd, upstart, etc). This way it launches on boot and will restart on any errors.

1 Like