[英]Socket.io on Cloud 9 IDE - warn: error raised: Error: listen EACCES
I am developing in the Cloud 9 IDE. 我正在使用Cloud 9 IDE进行开发。
This is the error I am receiving: 这是我收到的错误:
warn: error raised: Error: listen EACCES 警告:引发错误:错误:听EACCES
I am using the Port that Cloud 9 specifies to use in my code for listen: process.env.PORT 我正在使用Cloud 9指定在我的代码中使用的端口:listen:process.env.PORT
Here is my code: 这是我的代码:
//app.js Socket IO Test
var express = require("express"),
redis = require('socket.io/node_modules/redis'),
io = require('socket.io').listen(app);
var app = express();
var redisPort = [CENSORED]
, hostname = [CENSORED]
, password = [CENSORED]
, db = 1;
var pub = redis.createClient(redisPort, hostname);
var sub = redis.createClient(redisPort, hostname);
var store = redis.createClient(redisPort, hostname);
pub.auth(password, function(){console.log("adentro! pub")});
sub.auth(password, function(){console.log("adentro! sub")});
store.auth(password, function(){console.log("adentro! store")});
io.configure( function(){
io.enable('browser client minification'); // send minified client
io.enable('browser client etag'); // apply etag caching logic based on version number
io.enable('browser client gzip'); // gzip the file
io.set('log level', 1); // reduce logging
io.set('transports', [ // enable all transports (optional if you want flashsocket)
'websocket'
, 'flashsocket'
, 'htmlfile'
, 'xhr-polling'
, 'jsonp-polling'
]);
var RedisStore = require('socket.io/lib/stores/redis');
io.set('store', new RedisStore({redisPub:pub, redisSub:sub, redisClient:store}));
});
app.listen(process.env.PORT);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
var buffer = [];
io.sockets.on('connection', function(client){
var Room = "";
client.on("setNickAndRoom", function(nick, fn){
fn({msg : "Hello " + nick.nick});
client.join(nick.room);
Room = nick.room;
client.broadcast.to(Room).json.send({ msg: "Se conecto al room: " + nick.room, nick : nick });
});
client.on('message', function(message, fn){
var msg = message; //{ message: [client.sessionId, message] };
buffer.push(msg);
if (buffer.length > 15)
buffer.shift();
client.broadcast.to(Room).json.send(msg);
fn(msg);
});
client.on('disconnect', function(){
client.broadcast.to(Room).json.send({ msg: "Se desconecto"});
});
});
I'm not sure why I'm getting this error while using the port suggested by Cloud 9. 我不确定为什么在使用Cloud 9建议的端口时出现此错误。
Thanks in advance! 提前致谢!
你想在套接字听之前创建app = express()吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.