2

我要做的就是将我的小 nodeJS 应用程序部署到免费托管网站 appFog 上。无论我在客户端或服务器端设置了哪些端口。我一直收到错误消息:

事件.js:71

抛出参数[1];// 未处理的“错误”事件

^ 错误:听 EADDRINUSE

当这是在本地主机上运行的笔记本电脑/台式机上时,一切正常。

所以这就是我要做的:

客户端:

this.connection = new WebSocket('ws://super1onate.aws.af.cm:1337');

服务器端:

var express = require("express"); // load the express module 
var app = express(); // App now holds the server object

// What ports to listen on 
app.listen(process.env.VCAP_APP_PORT ||1337);  

server.listen(process.env.VCAP_APP_PORT || 1337, function() {
     console.log((new Date()) + " Server is listening on port " + webSocketsServerPort); });
4

2 回答 2

2

Your server code looks ok. What is events.js? It looks like maybe you're including a module that's trying to bind to a port it shouldn't.

Once you get your server running, I don't think your client code will work. As far as I can tell, AppFog doesn't support websockets, and if it does, you'll probably want to hit port 80, not 1337.

于 2013-02-14T05:17:07.513 回答
2

好吧,我会回答我自己的问题。

AppFog 不支持 WebSocket。websockets =/= socket.io btw fyi

无论如何,根据这个网站: http: //feedback.appfog.com/forums/171983-appfog/suggestions/3543100-add-websocket-support-to-node-js

于 2013-02-14T06:05:37.803 回答