Client socket.io.js not found 404
See original GitHub issueHi, I’m trying to use socket.io(0.9.6) with express (3.00b4) and node (0.8.1). On a localhost.
When I create the base epxress server the socket.io client is not found.
I’ve tried uninstalling everything and reinstalling it.
This is my app.js code
var socket = require('socket.io')
var express = require('express')
, routes = require('./routes')
, http = require('http');
var app = express();
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
app.use(app.router);
app.use(require('less-middleware')({ src: __dirname + '/public' }));
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function(){
app.use(express.errorHandler());
});
app.get('/', routes.index);
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
var server = http.createServer(app);
var io = socket.listen(server)
Issue Analytics
- State:
- Created 11 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
GET/ socket io not found 404 - node.js - Stack Overflow
The problem is in your server code. You bind socket.io to http , but only app listens on the port (5000). You need...
Read more >Error node js socket io socket io js not found - Edureka
Getting the error: /socket.io/socket.io.js 404 (Not Found) Uncaught ReferenceError: io is not defined. My code is:
Read more >Socket.io 404 Not Found when using express server
io.js” file in my “views” folder, but I have no idea if it auto-generated, or if I found one online and threw it ......
Read more >Node.js Socket.io Error when trying to connect client to server
src="/socket.io/socket.io.js". and client throws the Errors: Failed to load resource: the server responded with a status of 404 (Not Found).
Read more >Client Initialization | Socket.IO
In case your front is not served from the same domain as your server, you have to pass the URL of your server....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s your server. Not:
You’re basically creating two http servers, the latter of which is not listening on any port. It’s a zombie.
Turn your code into this:
Amazing!!! 🎉🎉