Tag: appfog

Node.js AppFog上的TCP Socket服务器

鉴于以下在AppFog上运行的简单的TCP套接字服务器,无论客户端发送什么,都会回应。 var net = require('net'); var server = net.createServer(function (socket) { socket.write('Echo server\r\n'); socket.pipe(socket); }); var port = process.env.VCAP_APP_PORT || 80; server.listen(port); console.log('Server running at ' + port); 我似乎无法连接到服务器。 它在我的本地开发机器上工作正常。 AppFog支持我所要做的吗? 我对Node.js比较陌生,所以我不能肯定地说代码是正确的。

快速AppFog上的错误,但不是在本地

我在AppFog上托pipe我的应用程序时出现错误。 50行,当我打电话给JSDOM …问题不出现在本地,我不明白为什么它不能在远程工作… 我的代码(在当地工作): exports.index = function(req, res) { Creation.findAll({where: "state = 1",order: 'id DESC', limit: 2}).success( function(creations) { Post.findAll({where: "state = 1",order: 'id DESC', limit: 2}).success(function(posts){ async.map(posts, function(postEntity, callback){ jsdom.env( // PROBLEM HERE postEntity.content, ["http://code.jquery.com/jquery.js"], function(errors, window) { if(errors) return callback(errors); postEntity.content = window.$("p").text(); callback(null, postEntity); } ); }, function(err, transformedPosts){ if(err) return callback(err); […]

更新和/或修复AppFog数据库的模式

我使用ExpressJS在NodeJS中创build了一个应用程序,我在AppFog上托pipe了我的应用程序,但是它工作正常,但是我在本地版本上做了一些更新,现在我想更新AppFog上的应用程序,但是我遇到了问题,在本地和现在更新我的模型,我无法更新我的AppFog数据库… 我想要做什么? 删除应用程序并再次更新? 我会在我的数据库中丢失所有的数据… 日志: Error: ER_BAD_FIELD_ERROR: Unknown column 'tags' in 'field list'

使用mongo-connect不会在AppFog上清除会话

我的会话没有在AppFog上清除。 我的设置如下: Node.js(与快递)mongoDB连接mongo的会议存储mongoHQ托pipe我的数据库。 我已经把我的本地设置连接到使用mongoHQ db实例,所有的会话都被清除了。 但是,当从AppFog运行应用程序的sesssions不会被清除。 我的会话中间件: app.use(express.session({ secret: 'my secret here', cookie: { maxAge: new Date(Date.now() + 360000)}, store: new MongoStore({ url: connectionEnv.dbConnection }) })); 这里是一个使用和清除会话的例子: console.log(req.session.errors); // Session has a value as intended res.render('contact', { user: username, email: email, messages: req.session.messages, errors: req.session.errors }); req.session.messages = null; req.session.errors = null; // The session […]

用node.js上传一个多人游戏

我在node.js做了一个游戏并上传了它,它应该是每秒30 – 60帧。 现在我testing它,它运行缓慢..我的意思是在本地networking运行更顺畅 服务器是不是很远..所以任何提示如何使fps更好? 什么是更好的xhr-pooling或websockets ,什么是更快? 游戏是这样设置的xhr-pooling – io.set('transports', ['xhr-polling']); 该游戏托pipe在appfog中 如果需要,我可以发布游戏链接!

AppFog node.js客户端无法加载socket.io

我只是将一个node.js站点部署到AppFog。 当我去“http:// localhost:8080”时,它在本地工作正常,但是当我到达AppFog上的一个: http ://bandwithfriends.aws.af.cm/时,我得到以下Chrome控制台错误: XMLHttpRequest cannot load http://localhost:8080/socket.io/1/?t=1357769454152. Origin http://bandwithfriends.aws.af.cm is not allowed by Access-Control-Allow-Origin. 服务器代码: var app = require('http').createServer(handler), io = require('socket.io').listen(app), static = require('node-static'); // for serving files // This will make all the files in the current folder // accessible from the web var fileServer = new static.Server('./'); app.listen(process.env.VCAP_APP_PORT || 8080); […]

节点+ mongo,不能插入到mongo,除非在本地主机上

出于某种原因,当我在本地运行时,以下插入到远程mongo服务器,但是当我在我的appfog服务器上运行它不插入。 function record_visit(req, res){ res.write("<br/>Connecting to "+mongourl+"<br/>"); mongo.connect(mongourl, function(err, conn){ res.write("<br/>mongo.connect success. Err = "+err+"<br/>"); conn.collection('ips', function(err, coll){ res.write("<br/>conn.collection called on collection ips, err = "+err+"<br/>"); object_to_insert = { 'ip': req.connection.remoteAddress, 'ts': new Date() }; coll.insert( object_to_insert, {safe:true}, function(err){ res.write("Inserted in collection 'ips' Err= "+err); res.end('<br/>Done\n'); }); }); }); } 我的输出是: Connecting to [correct authenticated […]

用NodeJS上传AppFog上的文件

我使用Express创build了一个NodeJS应用程序,我在AppFog上上传了我的应用程序,唯一的问题是我的应用程序中有一个file upload表单,用于上传应用程序的一些照片(用于“创build”表格)。 它在当地工作,但在AppFog上它不工作,也许AppFoglocking了上传文件…我不知道我应该怎么做…我的CHMOD目录是“0777”。 (对不起,我来自欧洲) 我的看法: form.admin(action='/creations/save', method='post', enctype='multipart/form-data') div label(for='title') Title input(type='text', name='title', placeholder='Title…') div label(for='thumbnail') Thumbnail input(type='file', name='thumbnail') div label(for='moodboard') Moodboard input(type='file', name='moodboard') input(type='submit', value='Save') input(type='reset', value='Cancel') 我的控制器: var saveFile = function(file, folder){ var file_tmp = file.path; var file_name = file.name; var file_type = file.type; var file = './uploads/'+folder+'/'+file_name; console.log(file); fs.rename(file_tmp, file, function(err){ if( […]

JSDom替代与全面Sizzle支持?

对于一些范围,我有一个在CloudFoundry上运行的应用程序。 由于在这里讨论的Contextify问题,我无法使用jsdom来做到这一点。 为了解决这个问题,我开始用Cheerioreplacejsdom,但是现在我已经意识到它并不完全支持我需要用来处理被抓取的数据的Sizzleselect器。 经过一番调查,我开始觉得自己碰到了一堵砖墙 – 还有另外一个解决这个问题的方法吗? 谢谢!

更新时出现AppFog错误

当我在我的appfog云托pipe中更新我的文件时,我总是得到这个错误。 Uploading Application: Checking for available resources: OK Packing application: OK Uploading (7K): OK Push Status: OK Stopping Application 'volkova': OK Staging Application 'volkova': OK Starting Application 'volkova': . Error: Application [volkova] failed to start, logs information below. ====> /logs/stderr.log <==== ./startup: line 3: /opt/cloudfoundry/runtimes/nodejs-v0.6.17/bin/node: Permission denied 这是什么原因,我该如何防止呢?