0

I am trying to include socket.io on the client-side. I keep getting this error message in the console every 5 seconds:

GET https://example.com/socket.io/?EIO=3&transport=polling&t=Lo8ssW0 404 (Not Found)

My code:

script(src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.2/socket.io.slim.js')
var socketio = io.connect('https://example.com',{secure: true, port:5089})

On the server-side I have:

const socketio = app.listen(5089)
var io = require('socket.io')(socketio)

which works correctly.

What am I doing wrong?

konyv12
  • 716
  • 2
  • 8
  • 23
  • Maybe that helps? https://stackoverflow.com/questions/29511404/connect-to-socket-io-server-with-specific-path-and-namespace – CFrei Jun 08 '17 at 18:26
  • No but I am losing my fvkin mind because what can possibly be wrong with this.. – konyv12 Jun 08 '17 at 19:07

1 Answers1

0

Simply replace

var socketio = io.connect('https://example.com',{secure: true, port:5089})

by:

var socketio = io.connect()

Does this help? If so, the problem is the host or the port in your original function call.

This simplified code should work, at least if you load the client from the server that runs Socket.io as well.

Golo Roden
  • 140,679
  • 96
  • 298
  • 425