Sunday, 2 May 2021

How to downgrade socket.io websocket to WS from WSS?

I am making a website that accesses the devices sensors and sends them via socket.io to my local machine. I can't access the device sensors without HTTPS, so I have to use HTTPS for the website, which is why I uploaded my site to Heroku. The problem is the localhost server I open on my computer is HTTP, and my HTTPS website can't send data from HTTPS (heroku site) to HTTP (local machine: localhost). Is there any way I can share the data between them?

This is the code used to connect to localhost written on the heroku client side site:

const socket = io("https://192.168.1.15:16", { transports: ['websocket', 'polling', 'flashsocket']});

While this is what I use in my local machine:

const httpServer = require("http").createServer(app);
const io = require("socket.io")(httpsServer,{

});

as per socket.io documentation



from How to downgrade socket.io websocket to WS from WSS?

No comments:

Post a Comment