Web socket - persistent connection

#1

Is this possible to connect from losant (workflow) to web socket and maintain persistent connection for unlimited time?

Best regards.
Mirek.

1 Like

#2

Opening a persistent websocket connection using a workflow is not possible. Cloud workflows have a 60 second timeout on any single execution. We have considered a websocket integration that would allow you to form a persistent connection and then trigger workflows on incoming messages. Would that work for your use case?

0 Likes

#3

That would work for some of our use cases.

0 Likes

#4

First of all thank you very much for fast answer,
I think it would work and at least it is worth to try. What I want to do is make a http request (undefined time) and wait for message, as you Brandon wrote above. Then, when message come I would trigger a workflow. Yes it sounds reasonably.
Sorry for my english.
Have a nice day.
Mirek.

0 Likes

#5

@paul_wareham @Mirek_Gadomski

One of the challenges with a Websocket integration is that the data is raw bytes, so we can’t automatically know where a message ends to trigger a workflow with it.

Do either of you use a standard protocol on top of Websockets? Something like socket.io?

0 Likes

#6

In an application context, we use J1939 (from the engine world) in Losant as a top level protocol and parse it within the platform, which is carried over a proprietary UDP-based protocol from the cellular gateway vendor.

We have not used either of these protocols with Websocket however. sockets.io seems like a great starting point though.

0 Likes

#7

Hello Brandon, Evan.
I’m not sure that my knowledge is enough deep to pass valuable
information to you. In few sentences I’ll describe what I need to do.
Controller that I use is Seeed Studio Wio Node/Link with button connected to
it. Controller has predefined firmware that sends data to server with REST API
service. The benefit is that there is no need to program the controller. Seeed
Studio’s server doesn’t keep any historical data, so I have to pick it up
before it gone. Some information (data) for example temperature, humidiy is
easy to collect. Its enough to make http request every one minute or so. But
there is also event type data, generated by, for example: button or PIR sensor.
That event is passed by websocket. Below is example of connection in javascript:

image

The response message is json formatted and looks like below:

[5] RECV: {“msg”: {“button_pressed”: “3”}}
[4] RECV: {“msg”: {“button_pressed”: “3”}}
[3] RECV: {“msg”: {“button_pressed”: “3”}}
[2] RECV: {“msg”: {“button_pressed”: “3”}}
[1] SENT: ……your token…….
[0] CONNECTED

Best regards.
Mirek.

0 Likes