mjanisz1
mjanisz1

Reputation: 1516

Sockets can't find source files in frontend

Im using the template for express and angular from this tutorial.

Installed socket.io using npm and the files are visible in node_modules. Server starts normaly (I hope) with info - socket.io started visible in the console.

I run it by changing the server.js file from the template.

var app = express()
    , server = http.createServer(app)
    , io = require('socket.io').listen(server)

and passing io to the files i'll be using it in like:

require('./config/routes')(app, passport, auth, io)

In the frontend (like in the example on sockets.io) website I add it by simply:

script(type='text/javascript', src='socket.io/socket.io.js')

but I get

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/socket.io/socket.io.js

Any help would be appreciated!

Upvotes: 0

Views: 129

Answers (1)

moka
moka

Reputation: 23047

Check your code for the way you are initializing web server listener socket. This is not socket listener, but web server one.

In express it is usually:

app.listen(3000);

But you need to do:

server.listen(3000);

*Assuming that this is problem taking in account lack of full source code and missing exactly that part in your question code.

Upvotes: 2

Related Questions