端口34037已经在使用Heroku + Nodejs + Express + WebSockets

我试过了我能find的所有东西,但是我无法让我的部署工作。 我不断收到'应用程序错误',虽然应用程序运行在我的http:// localserver:5000似乎问题是在bin / www

这是我在Heroku中得到的错误日志。 我想这个问题是“ 端口34037已经在使用

pp[web.1]: > tubka@0.0.0 start /app 2015-02-04T09:29:03.327577+00:00 app[web.1]: > node ./bin/www 2015-02-04T09:29:03.327578+00:00 app[web.1]: 2015-02-04T09:29:03.695715+00:00 app[web.1]: http server listening on 34037 2015-02-04T09:29:03.761305+00:00 app[web.1]: npm ERR! You can get their info via: 2015-02-04T09:29:03.744365+00:00 app[web.1]: Port 34037 is already in use 2015-02-04T09:29:03.761400+00:00 app[web.1]: npm ERR! npm owner ls tubka 2015-02-04T09:29:03.759922+00:00 app[web.1]: npm ERR! tubka@0.0.0 start: `node ./bin/www` 2015-02-04T09:29:03.761610+00:00 app[web.1]: npm ERR! There is likely additional logging output above. 2015-02-04T09:29:03.760193+00:00 app[web.1]: npm ERR! 2015-02-04T09:29:03.762242+00:00 app[web.1]: npm ERR! command "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start" 2015-02-04T09:29:03.760053+00:00 app[web.1]: npm ERR! Exit status 1 2015-02-04T09:29:03.762111+00:00 app[web.1]: npm ERR! System Linux 3.13.0-40-generic 2015-02-04T09:29:03.760836+00:00 app[web.1]: npm ERR! This is most likely a problem with the tubka package, 2015-02-04T09:29:03.762374+00:00 app[web.1]: npm ERR! cwd /app 2015-02-04T09:29:03.760300+00:00 app[web.1]: npm ERR! Failed at the tubka@0.0.0 start script. 2015-02-04T09:29:03.762511+00:00 app[web.1]: npm ERR! node -v v0.10.35 2015-02-04T09:29:03.760965+00:00 app[web.1]: npm ERR! not with npm itself. 2015-02-04T09:29:03.762654+00:00 app[web.1]: npm ERR! npm -v 1.4.28 2015-02-04T09:29:03.761073+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system: 2015-02-04T09:29:03.762777+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2015-02-04T09:29:03.761194+00:00 app[web.1]: npm ERR! node ./bin/www 2015-02-04T09:29:03.766267+00:00 app[web.1]: npm ERR! Additional logging details can be found in: 2015-02-04T09:29:03.766925+00:00 app[web.1]: npm ERR! not ok code 0 2015-02-04T09:29:03.766121+00:00 app[web.1]: npm ERR! 2015-02-04T09:29:03.766678+00:00 app[web.1]: npm ERR! /app/npm-debug.log 2015-02-04T09:29:03.718169+00:00 app[web.1]: websocket server created 2015-02-04T09:29:03.753343+00:00 app[web.1]: 2015-02-04T09:29:04.473160+00:00 heroku[web.1]: Process exited with status 1 2015-02-04T09:29:04.482618+00:00 heroku[web.1]: State changed from starting to crashed 2015-02-04T09:29:59.234120+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=tubka.herokuapp.com request_id=4edf0fd1-1231-440b-ac4a-4a21733e623f fwd="88.192.84.193" dyno= connect= service= status=503 bytes= 2015-02-04T09:30:00.283732+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=tubka.herokuapp.com request_id=3fdcf81e-c40f-4770-ae0f-d83a7e672d1f fwd="88.192.84.193" dyno= connect= service= status=503 bytes= Internetz:gagtube alexandertazh$ 

我遵循Heroku文档来部署带有ws模块的websockets 。 这里是我的app.js的一部分Nore部分var port = process.env.PORT || 5000

 **var express = require('express') var http = require("http"); var Crawler = require("simplecrawler"); var cheerio = require('cheerio'); var fs = require('fs'); var path = require('path'); var favicon = require('serve-favicon'); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var routes = require('./routes/index'); var app = express(); var port = process.env.PORT || 5000 var server = http.createServer(app) server.listen(port) console.log("http server listening on %d", port) var WebSocketServer = require('ws').Server var wss = new WebSocketServer({server: server}) console.log("websocket server created") wss.on("connection", function(ws) { fs.readFile('./playlist.json', 'utf-8', function(err, data){ if (err) throw err; ws.send(data); console.log(data); }); console.log("websocket connection open") ws.on("close", function() { console.log("websocket connection close") }) })** 

和客户端:

 var host = location.origin.replace(/^http/, 'ws') var ws = new WebSocket(host); ws.onmessage = function (event) { playthelistclient.push(event.data); }; 

我关于端口的bin / www文件部分:

 var port = normalizePort(process.env.PORT || '3000'); app.set('port', port); 

希望你们能帮忙。

       

网上收集的解决方案 "端口34037已经在使用Heroku + Nodejs + Express + WebSockets"