Possible Duplicate:
socket.io: Failed to load resourcesocket.io +快遞networkerror:404個
一個簡單的快遞+ socket.io hellow世界的應用程序似乎不工作,我不斷收到
"NetworkError: 404 Not Found - http:// localhost:3002/socket.io/socket.io.js"
任何人都知道這個問題?
代碼:
app.js
var express = require('express'),
http = require('http');
var app = express();
var server = http.createServer(app);
var io = require('socket.io').listen(server);
app.configure(function() {
app.use(express.static(__dirname + '/public'));
});
app.listen(3002);
io.sockets.on('connection', function(socket) {
socket.emit('news', {hello: 'world'});
socket.on('my other event', function (data) {
console.log(data);
});
});
的index.html
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://localhost');
socket.on('news', function (data) {
console.log(data);
socket.emit('my other event', { my:'data' });
});
[「404或Not Found錯誤消息是HTTP標準響應代碼指示客戶端能夠與服務器通信,但服務器找不到所請求的內容。「](http://en.wikipedia.org/wiki/HTTP_404) – Engineer 2012-07-26 07:49:23
是的,但代碼有什麼問題導致這個問題? – nihulus 2012-07-26 08:00:06