Web sockets allows multiple external applications to subscribe to events, unlike webhooks which only allows for one subscriber at a time. Web Sockets also enables real-time sync within LubeLogger which is the ideal approach for [[Kiosk|Advanced/Kiosk]] mode.
+
+
Web socket can be enabled in the [[Server Settings Configurator|Installation/Server Settings]]
+
+

+
+
## Testing WebSocket Connection
+
+
Web sockets are implemented through SignalR hubs, which provides fallbacks such as SSE and long-polling if operating under unsupported environments. For this example, we will assume that web sockets are enabled and supported.
+
+
In PostMan(or your preferred RestApi tester), select WebSocket as the connection type:
+
+

+
+
If authentication is enabled, you will need to generate an api key(viewer permission) and append it. If your LubeLogger instance is served over a https connection, use `wss://` otherwise use `ws://`
You will then send a few messages to set the protocol and join either one of these groups:
+
+
- kiosk
+
- vehicleId_{id of the vehicle}
+
+
The `kiosk` group allows you to subscribe to changes across all vehicles in the system, where as the vehicleId_{id of the vehicle} group allows you to subscribe to changes only from that vehicle.
+
+
Because the messages contains the non-printing character `0x1e` (RS), they can be found on this [gist](https://gist.github.com/hargata/d9dc0ce127e6fb24f877886a7e395c2e) instead of being in this wiki.
+
+
This message sets the protocol
+
+

+
+
This message joins the kiosk group
+
+

+
+
This message joins the group for vehicleId 1
+
+

+
+
If you're already joining the kiosk group, joining the vehicleId groups is redundant.
+
+
## Notes on WebSocket Security
+
+
Note that ANY user can subscribe to ANY group, which means, that if a user has a valid API key, they can subscribe to events from any vehicles, even those they don't have access to. Only enable web sockets if you are the only user in your instance or if you fully trust all of the users in your instance. Much like webhooks, the web socket implementation in LubeLogger is one-way, meaning that users can consume events but not transmit any events back to the server via webhooks.