Monday, 3 April 2017

Cannot get /socket.io/socket.io.js on client application

My server side application is hosted on heroku: https://shielded-dusk-72399.herokuapp.com/

Relevant code looks like this:

const
    express = require('express'),
    app = express(),
    server = require('http').createServer(app),
    io = require('socket.io').listen(server),
    port = process.env.PORT || 8080

server.listen(port, (err) => {
  console.log(err || 'listening on my very special port ' + port)
})

In my heroku logs this gets logged: "listening on my very special port 28428"

Now on my client application:

Currently my client application is running on port 8080

In my index.html:

<script>/socket.io/socket.io.js" charset="utf-8"></script>

When I go to localhost:8080 I get the following errors:

Cannot GET http://localhost:8080/socket.io/socket.io.js

Other Attempts:

<script src="https://shielded-dusk-72399.herokuapp.com:28428/socket.io/socket.io.js" charset="utf-8"></script>

Cannot GET https://shielded-dusk-72399.herokuapp.com:28428/socket.io/socket.io.js net::ERR_CONNECTION_REFUSED

<script src="https://shielded-dusk-72399.herokuapp.com:8080/socket.io/socket.io.js" charset="utf-8"></script>

Cannot GET https://shielded-dusk-72399.herokuapp.com:8080/socket.io/socket.io.js net::ERR_CONNECTION_REFUSED

And then I copied ./node_modules/socket.io-client/dist/socket.io.js to resources/js and get this error:

Cannot GET http://localhost:8080/resources/js/socket.io.js 404 (Not Found)

Any ideas?

I've used these all as references and still coming up short:

node.js /socket.io/socket.io.js not found

Node.js /socket.io/socket.io.js not found express 4.0

Can't get socket.io.js



via user2456977

No comments:

Post a Comment