在appFog上运行NodeJS应用程序

Run NodeJS app on appFog

本文关键字:NodeJS 应用程序 运行 appFog      更新时间:2023-09-26

我只想把我的小nodeJS应用程序部署到免费的托管网站appFog上。不管我在客户端或服务器端设置了什么端口。。我一直收到错误消息:

events.js:71

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

^错误:侦听EADDRINUSE

当它在我的笔记本电脑/台式机上运行时,一切都很好。

这就是我要做的:

客户端:

this.connection=新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); });

您的服务器代码看起来不错。什么是events.js?看起来可能您包含了一个模块,该模块正试图绑定到不该绑定的端口。

一旦你的服务器运行起来,我认为你的客户端代码就不能工作了。据我所知,AppFog不支持websocket,如果支持的话,您可能会想要访问端口80,而不是1337。

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

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

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