Flic HUB SDK Error connecting to a remote websocket server (wss)



  • Hello,

    I'm trying to connect my HUB to a remote websocket server, but none of the solutions i tried worked. I'm using the 'net' library becausa is the given by SDK and i can't use others like socket.io. The server domain starts with "wss://...", but if i use it, that gives me an Error ECONNREFUSED (connection refused). If i remove the part "wss://..." of the domain and set the port to 443 IT SAYS THAT THE CONNECTION WAS MADE, but i checked my server and the HUB IS NOT CONNECTED to the WSS server.
    If i use the same code, but changing the server domain to a local ip address it works fine. So i don't know if the problem is the fact that is a remote WSS server, but i think the code is not wrong.

    Code :

    var client1 = net.createConnection(433, domain, function() {
    console.log("Connected")
    });

    client1.on("data", function (data) {
    console.log(data.toString());
    })

    client1.on("end", function () {
    console.log("ended");
    })

    client1.on("error", function (data) {
    console.log(data);
    })


  • FlicTeam

    @antonio-mestre the net module implements just a raw TCP socket. The secure web socket protocol uses the Websocket protocol on top of the TLS protocol on top of the TCP protocol.

    Right now our sdk unfortunately does not include modules for TLS (but we have https) nor Websocket, so you would have to implement that yourself if you want to use wss, using the net module in the bottom for TCP.