でセットアップsocket.ioしようとしている:私はExpressのセットアップSocket.ioにしようとしている、と私はこれでSocket.ioドキュメントからの正確なコードを使用していエクスプレス
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen(80);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
io.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
app.jsを実行しているときにエラーが発生しています。
events.js:141
throw er; // Unhandled 'error' event
^
Error: listen EACCES 0.0.0.0:80
at Object.exports._errnoException (util.js:849:11)
at exports._exceptionWithHostPort (util.js:872:20)
at Server._listen2 (net.js:1218:19)
at listen (net.js:1267:10)
at Server.listen (net.js:1363:5)
at Object.<anonymous> (/Users/leondewit/PhpstormProjects/websocket_test/app.js:5:8)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
何か間違っている可能性がありますか?
実行中のポートを80から8080に変更し、アプリケーションを再起動してください – eGhoul
ありがとう、本当に問題でした! – Leon