0

this is hte link on my app: https://intense-inlet-33140.herokuapp.com/ u can see there what axactly the error I have.

It looks like:

bundle.js:2391 GET https://intense-inlet-33140.herokuapp.com/socket.io/?EIO=3&transport=polling&t=Lt2mQC9 404 (Not Found)

the code regarding that I have: server side app.js:

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

app.set('port', (process.env.PORT || 5000));
app.use(express.static(__dirname + '/public'));

Html:

script(src='/socket.io/socket.io.js')

And bundle.js client side:

var io = require('socket.io-client');
var socket = io.connect('https://intense-inlet-33140.herokuapp.com/', {
  'path': '/socket.io/'
});
this.io = socket.connect('/socket.io/', {
  transports: ['websocket'],
  upgrade: false,
});

My app running on the Heroku.

What exactly should I put there io.connect( ??? ) and there socket.connect( ??? , {

I know it must be a path to... socket? I don't understand it well and I tried different options, but there are still the same errors. Help please.

  • Now I have WebSocket connection to 'wss://intense-inlet-33140.herokuapp.com:5000/socket.io-client/?EIO=3&transport=websocket' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED changed code to: var socket = io.connect('https://intense-inlet-33140.herokuapp.com:5000', { 'path': '/socket.io' }); this.io = socket.connect('/socket.io-client', { transports: ['websocket'], upgrade: false }); – Dmytro Ilhanaiev Aug 08 '17 at 17:25

1 Answers1

0

First, about your server side:

app.set('port', (process.env.PORT || 5000));
app.use(express.static(__dirname + '/public'));

You have use port 5000 for WS (not sure you change it to 80 or not)

But in client you connected to WS via PORT 80. So please make sure both of side is same port. Base on your code:

var socket = io.connect('https://intense-inlet-33140.herokuapp.com/', {
  'path': '/socket.io/'
});

It should replaced by (I remove path because your server not declare custom path, so client don't need do that):

var socket = io.connect('https://intense-inlet-33140.herokuapp.com:5000');

don't forget open PORT if you have firewall.

datpp
  • 11
  • 1
  • ty a lot for ur answer. I did what u said. I mean var socket = io.connect('https://intense-inlet-33140.herokuapp.com:5000'); now I have that arror: bundle.js:2391 GET https://intense-inlet-33140.herokuapp.com:5000/socket.io/?EIO=3&transport=polling&t=Lt2yMoM net::ERR_CONNECTION_REFUSED – Dmytro Ilhanaiev Aug 08 '17 at 17:45
  • "You have use port 5000 for WS (not sure you change it to 80 or not)" I dont change it And now I turned off my firewall, but there are the same errors – Dmytro Ilhanaiev Aug 08 '17 at 17:56
  • forgot you have connected via SSL. Check this article maybe it help you https://stackoverflow.com/questions/21651133/setup-server-server-ssl-communication-using-socket-io-in-node-js – datpp Aug 08 '17 at 18:36