socket.io + node.js on heroku

前端 未结 6 1228
后悔当初
后悔当初 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条回答
  • 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..

    0 讨论(0)
  • 2021-01-03 07:39

    Heroku is failing to build hiredis. The reason is that hiredis (the node.js module) depends on hiredis (the C library), which needs GNU make, which is not available on your slug.

    Question is, why is NPM trying to build hiredis while it's not in your dependencies ?

    You should check if hiredis appears anywhere in your project (grep -R hiredis .). Another possibility is that Heroku is trying to provide redis to all node.js apps ?

    I'd check with Heroku's support.

    0 讨论(0)
  • 2021-01-03 07:42

    WAAAAAAAIT A SECOND.

    I noticed after I ran grep -R hiredis . that under the directory ./node_modules/socket.io/node_modules there appears the folder redis. Apparently, socket.io is now shipping with redis built in, which messes with Heroku.

    Try fooling around with removing the redis folder from socket.io's node_modules folder. I solved the issue by removing socket.io altogether.

    0 讨论(0)
  • 2021-01-03 07:51

    When you run npm install locally, hiredis creates some files with paths that are specific to your machine. When you push these cached dependencies to Heroku, the build fails.

    Waf: Entering directory `/Users/gaggina/Desktop/socket2/node_modules/socket.io/node_modules/redis/node_modules/hiredis/build'
    

    You can get around this problem by removing the node_modules/hiredis directory from source control, letting Heroku compile it anew:

    git rm -rf node_modules/hiredis
    rm -rf node_modules/hiredis
    echo "node_modules/hiredis" >> .gitignore
    
    0 讨论(0)
  • 2021-01-03 07:53

    I've posted an answer to a similar question at deploy nodejs to heroku and that seems to have solved the problem.

    Basically try using socket.io 0.9.6 instead of 0.9.8.

    0 讨论(0)
  • 2021-01-03 08:00

    I was running into the same problem while messing around with heroku. All the paths seemed to be there. Running Ubuntu 12.04 and I even created a sym link for gmake. Nothing fixed it. I tried this eventually

    "dependencies": {
      "express": "3.0.0rc2",
      "ejs": "*",
      "stylus": "*",
      "mongojs": "0.4.3"
    },
    "bundledDependencies": {
      "socket.io": "*"
    },
    

    instead of

    "dependencies": {
      "express": "3.0.0rc2",
      "ejs": "*",
      "stylus": "*",
      "mongojs": "0.4.3",
      "socket.io": "*"
    },
    

    and this seemed to fix it and make heroku happy. If you find a proper solution, do let me know.

    0 讨论(0)
提交回复
热议问题