Support for Websockets in Edge

Have tried to add support in a Edge driver for Websocket (client) using GitHub - lipp/lua-websockets: Websockets for Lua., that is written in pure Lua, without success.

Has anyone been able to add Websockets support in Edge?

1 Like

FYI, I have now managed to add support for lua-websockets in Edge. The main problem was actually a known bug regarding the implementation of PING/PONG in the module.
To make it work with the Edge event loop, I also had to adapt the code to cosock socket and cosock ssl (wss).

Adapted code here: GitHub - Goran58/lua-websockets: Websockets for Lua.


Hi Gol

I’m trying to add in your customised websocket library but I’m having difficulty (im a lua novice, so it’s probably something basic that I am missing)

I have downloaded the websockets library and installed it using luarocks

This is my path…

echo $LUA_PATH

and websockets appears to be in /home/louis/.luarocks/share/lua/5.3/

But when i install my driver to ST i get the following in logs

2021-12-03T15:48:22.529491679+00:00 FATAL Hello World  Lua: runtime error: [string "init.lua"]:5: Module 'websocket.client' not found
stack traceback:

Is there something special i have to do to make smartthings bundle the library when i package it?

Thank you

Instead of changing the LUA_PATH it is probably easier to copy all files from the lua-websockets src-directory to the src-directory of your Edge-driver.

Thanks, not really sure why I didn’t think of trying that.

Incase you are interested, I’m going to attempt to see if I can speak to my Logitech harmony hub over websockets. I’ve found a nodejs library that does exactly that, so I’m going to see if I can rewrite some of the functionality in lua, and then figure out how to present the devices connected to the harmony hub as devices in st.

I just don’t get the most amount of time to work on it so it’s probably going to take me a while.

What was you communicating with over websockets? Thanks



I intended to develop a driver for integration with a burglary alarm system (Vanderbilt SPC). The communication is based on HTTPS and Websockets.
But actually, after spending two weeks struggling with the issues in the beta-version of the Edge SDK, I have decided to pause the development until ST provide a stable version of the SDK.


Hi Gol & Louis,

Glad to hear someone were trying to do something similar. Just want to know if you can share with what issues did you encounter and make you decide to pause at present?

@taustin has a couple of working websocket projects for Edge. They are still in beta because Edge itself is still in Beta, but you can take a look. you can find them (and any future offerings) from the quick browse lists in the community-created wiki:

1 Like

FYI, my drivers usually don’t use any third party libraries. My webhook, RESTful interfaces are implemented with vanilla sockets.


I guess the driver isn’t open sourced? Since I can’t seem to find link to source.

Which driver are you looking for? I have several Edge drivers in my public github repositories.


I have posted about the driver I am working on here, I was able to get websockets working but had to change the library @gol shared and even hardcode some of the handshake behaviour as i was unable to get that bit to work in ST edge driver


Great! Thanks.


@lmullineux Hi, I tried your driver’s websocket to a ws server, but got hand shake failure. The error was due to wrong Sec-Websocket-Accept header. Since I was able to connect to the ws server via a standard websocket client, I believe the server part should be fine.
Do you think is possible the ws lua client was the culprit?

Hi, I skimmed through your repos, could not find a websocket client, can you point me to a driver used the websocket?
Also, I used mdns for service discovery. It’s sort of working in my environment (thanks to MDNS failure - #2 by erickv), but do you know is there a way to keep the mdns running in a dedicated thread so that our driver can be notified anytime a service is online or offline.

It’s almost certainly the client yes.

As I said in my post getting the handshake to work was the exact problem I was getting.

I ended up hardcoding the expected response because I couldn’t get sha1 working.

I was able to do this because the device I was using always sends the same value, and the guid was fixed.

You should be able to do the same approach if the value sent is always the same. Have a look at the sec_websocket_accept function of the handshake file within the websocket folder. ( If the value changes though you will need to try and get sha1 working on the hub)


Thanks for the update.

I found out the cuase (possibly), the server was returning a plain http response because the ws request isn’t allowed. So, I guess the problem is not with the lua ws client. I’ll investigate more and let you know if it still not work.


What are you trying to communicate with?

Have you figured out what sort of ws client you need? I was using sync client so have only tested/fixed that client

I’m trying to support Terncy hub (

The problem was I passed a wrong authentication code while connecting to the hub. After I corrected it, it worked fine.


Great - I hope you get it all working