Answer the question
In order to leave comments, you need to log in
I can't connect to socket io from hosting, problems with HTTPS?
Background.
I have a site on a hosting, which is connected to the ssl protocol.
There is also a server with OC Ubuntu 18.04, nginx, node js, socket.io is installed here.
The problem is that I cannot connect to the server from the site, because ssl is connected to the site, but not on the server.
Here is the file that is on the server, respectively, which I run.
index.js
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res) {
res.sendfile('index.html');
});
//Whenever someone connects this gets executed
io.on('connection', function(socket) {
console.log('A user connected');
//Whenever someone disconnects this piece of code executed
socket.on('disconnect', function () {
console.log('A user disconnected');
});
});
http.listen(3000, function() {
console.log('listening on *:3000');
});
<script type="text/javascript">
var socket = io.connect('http://ip_servera:3000/');
</script>
Answer the question
In order to leave comments, you need to log in
Put ssl on the second. The security policy prohibits accessing http resources from a site on https
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question