11.05.2021, 09:30
(11.05.2021, 07:08)admin Wrote: 1. Install 2021 RC1 firmware.
2. Create a user library named websocket using the attached source.3. Upload certificates via FTP using ftp login, rename files with long names to cert.pem and key.pem accordingly.
4. Create a resident script with 0 sleep time.
Code:if not client then
require('json')
ws = require('websocket')
url = 'wss://test-hub.usbim.com'
client, err = ws.client('sync', 1)
opts = {
protocol = 'tlsv13',
key = '/home/ftp/key.pem',
password = [[*q&'wrKQsx+#bj8pbEV=%7Gpr"S+sxV2ngr`N}SjCC`X#rtt!wY6PL`d2'3!^x}u]],
certificate = '/home/ftp/cert.pem',
cafile = '/home/ftp/ca-chain.cert.pem',
}
res, err = client:connect(url, opts)
if not res then
log('connection failed', err)
client:sock_close()
client = nil
end
end
if client then
frame, opcode, clean, code, reason = client:receive()
log(frame, opcode, clean, code, reason)
if frame then
data = json.pcdecode(frame)
log(data)
elseif reason ~= 'timeout' then
log('connection dropped', reason)
client:sock_close()
client = nil
end
end
This example is only a starting point, it should be extended with additional send/receive logic.
Thank you very much.... now I am getting that log.... I guess something is still wrong...