A
A
andrey_270812020-10-15 14:13:00
Nginx
andrey_27081, 2020-10-15 14:13:00

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');
});


And this is how I connect to the server on the site
<script type="text/javascript">
    var socket = io.connect('http://ip_servera:3000/');
  </script>


Writes an error that there are problems with https

I tried to connect from another site, which without an ssl certificate, everything works fine

So the question is, how can I turn everything around so that I can connect to the server from the site with https, or in which direction to even think?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2020-10-15
@inoise

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 question

Ask a Question

731 491 924 answers to any question