Here is my server side:
var fs = require('fs');
var options = {
key: fs.readFileSync('/cert.key'),
cert: fs.readFileSync('/cert.crt')
};
var app = require('express')();
var http = require('https').Server(options, app);
var io = require('socket.io')(http);
var port = 1234;
app.get('/', function(req, res){
res.sendFile(__dirname + '/../subdomains/labs/socketio.html');
});
io.on('connection', function(socket){
socket.on('chat message', function(msg){
io.emit('chat message', msg);
});
});
http.listen(port, function(){
console.log("\n\n--------------------------------");
console.log('Currently Listening on port %d',port);
console.log("--------------------------------\n\n");
});
And my client side:
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script>
var socket = io('https://labs.domain.com:1234');
$('form').submit(function(){
socket.emit('chat message', $('#chat-message').val());
$('#chat-message').val('');
return false;
});
socket.on('chat message', function(msg){
$('#messages').append($('<li>').text(msg));
});
</script>
All works fine in internet explorer (agh!) But when using it in chrome it dies:
GET https://labs.domain.com:1234/socket.io/?EIO=3&transport=polling&t=1463123926844-3 net::ERR_INSECURE_RESPONSE
It works fine in both browsers if I remove the HTTPS aspect of it.
It's quite frustrating as it seems to be an issue with Chrome only, which is the browser I use the most. How can I fix this?