socket.io + node.js on heroku

前端 未结 6 1231
后悔当初
后悔当初 2021-01-03 06:55

I\'m having some issues in compiling a socket.io app on heroku.

Thats the app.js file

var app = require(\'express\').createServer()
   , io = require         


        
6条回答
  •  -上瘾入骨i
    2021-01-03 07:38

    I did some googling but cant find the solution, But i tried to change my code as below and it started to work...

    var express = require('express'),
        app = express(), 
        server = require('http').createServer(app),
        io = require('socket.io').listen(server),
    
    var port = process.env.PORT || 5000; // Use the port that Heroku provides or default to 5000
    
    server.listen(port, function() {
    });
    
    io.configure(function () {
        io.set("transports", ["xhr-polling"]);
        io.set("polling duration", 10);
        io.set("log level", 1);
    });
    

    let me know if you same issue and still not getting success..

提交回复
热议问题