I have read some of the articles and knows that you need xhr-polling for socket.io to work on heroku, and this is what I have so far:
var app = require('http').createServer();
var io = require('socket.io').listen(app, {origins: '*:*'});
io.configure(function () {
io.set("transports", ["xhr-polling"]);
});
io.sockets.on('connection', function(socket) {
console.log("Connected...");
socket.on('message', function(message) {
console.log("Message in:" + message.toString());
}
}
This code sometimes works, sometimes it stop at console.log("Connected...")
and won't go into socket.on('message', function(message)
. I have no idea why it only works whenever it feels like it. I have also tried restart the app but still not working.