Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs with socket.io on heroku

I'm trying to run a nodejs application with express and socket.io on heroku and it comess out with this error

EACCESS, Permission denied

when i try to run following code:

app.configure(function () {
   app.set('port', process.env.PORT || 3000);
});
var server = http.createServer(app).listen(app.get('port'))
io = require('socket.io').listen(server); // it crashes on this line
io.configure(function () {
    io.set("transports", ["xhr-polling"]);
    io.set("polling duration", 10);
    io.set("log level", 1);
});

Is it even possible to do this on heroku?

dependencies:

"socket.io": "*",
"express": "3.0.0rc4",
like image 361
Kikaimaru Avatar asked Nov 04 '22 14:11

Kikaimaru


1 Answers

Check this link: using socket.io with node.js on heroku.

[UPDATE 1]

Check this answer, which I think can help you troubleshooting your problem.

[UPDATE 2]

A link to a question that has working code (regardless of the client's bug, the motivation of the question itself).

var port = process.env.PORT || 3000;

var app = require('express').createServer()
var io = require('socket.io').listen(app);

app.listen(port);

// Heroku setting for long polling
io.configure(function () { 
    io.set("transports", ["xhr-polling"]); 
    io.set("polling duration", 10); 
});

// To set handlers for data received, etc ... use io.sockets.on('...', ...)
like image 144
fableal Avatar answered Nov 09 '22 14:11

fableal