简体   繁体   中英

Socket.IO ERR_CONNECTION_REFUSED

I am getting this error:

WebSocket connection to 'ws://localhost:8000/socket.io/?EIO=3&transport=websocket' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

错误

I have looked for this error but it seems for me that my configuration of the sockets is well and I do not think is for the warning of electron.

var express  = require('express');
var app      = express();
var server   = require('http').Server(app);
var io    = require('socket.io')(server);

var JSONTCPSOCKET = require('json-tcp-socket');
var JSONTCPSOCKET = new JSONTCPSOCKET({tls: false});


require("./rabbit")(io, JSONTCPSOCKET);
  var socket = io('http://localhost:8000',{transports: ['websocket',
    'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling', 'polling']});

Any idea?

Thanks mates!!

It was a silly mistake.

The file that contains the server that listen in that port is in my case server.js.

When you run it with node, the start file is server.js but when you run it with electron the start file is main.js and I was never running server.js when I executed with electron, so I was not listening in that port.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM