I'm making a whiteboard app:
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
io.on('connect', function(socket) {
socket.on('join', function(data) {
socket.join(data.room);
console.log(data.room);
});
socket.on('drawing', function(data) {
console.log(data);
io.sockets.in(data.room).emit("senddraw", data);
});
socket.on('writetext', function(data) {
console.log(data);
io.sockets.in(data.room).emit("senddraw", data);
});
socket.on('action', function(data) {
console.log(data);
io.sockets.in(data.room).emit("action", data);
});
});
http.listen(8080, function() {
console.log('listening on localhost:8080');
});
If I run this node script on my server, I can connect via my localhost copy of my webpage. However, I canon't connect from the copy hosted on my server as it's served over HTTPS. I get the error:
polling-xhr.js:264 Mixed Content: The page at: ***** was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://...*:8080/socket.io/?EIO=3&transport=polling&t=Lu2NoGL'. This request has been blocked; the content must be served over HTTPS.
How can I make resolve this without disabling ssl on my server?
Client has something equivalent to:
//var socket = io.connect("http://localhost:8080");
var socket = io.connect("http://**.***.***.**:8080");
socket.on("connect", function(data) {
socket.emit("join", {room : "@roomid"});
});
On drawing events:
socket.emit("drawing", {x0 : x0, y0 : y0, x1 : x1, y1: y1, current : current, room : "@roomid"});
Which are picked on by:
socket.on("drawing", function(data) {do blah});