A
A
artyak11212019-08-16 13:53:25
Socket.io
artyak1121, 2019-08-16 13:53:25

Why doesn't socket.io work?

Connecting socket.io on the service side goes like this:

var auth = require('http-auth'),
    scribe = require('scribe-js')(),
    console = process.console,
    config  = require('./config.js'),
    app     = require('express')(),
    server  = require('http').Server(app),
    io = require('socket.io')(server),
  fs = require('fs'),
  //privateKey = fs.readFileSync('/etc/letsencrypt/live/' + config.domain + '/privkey.pem'),
    //certificate = fs.readFileSync('/etc/letsencrypt/live/' + config.domain + '/cert.pem'),
    //credentials = {key: privateKey, cert: certificate},
    //http = require('http').Server(credentials,app);
  http = require('http').Server(app);
    redis   = require('redis'),
    requestify   = require('requestify');

var redisClient = redis.createClient(),
    client = redis.createClient();
    

server.listen(config.serverPort);

console.tag('SOCKET', logTime()).log('Сервер запущен на ' + config.domain + ':' + config.serverPort);

And in the js of the site it says:
if (START) {
    var socket = io.connect(':2053');
  var CurrentPage = document.location.pathname;
  socket

But the site console swears:
GET https://site:2053/socket.io/?EIO=3&transport=polling&t=MoQ3aKg net::ERR_FAILED
(index):1 Access to XMLHttpRequest at 'https://site:2053/socket.io/?EIO=3&transport=polling&t=MoQ3a_
GET https://site:2053/socket.io/?EIO=3&transport=polling&t=MoQ3a_B net::ERR_FAILED

What could be the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question