在node.js中运行应用程序时出现连接超时错误
connection timed out error in running the app in node.js
当我运行我的node js应用程序给节点app.js,设置NODE_ENV =生产,它不是被设置为生产,而是它给了连接超时错误,当我运行应用程序。我想它实际上得到连接与蒙古ab请等待您的建议。提前谢谢你。
C:'Users'Desktop'myapp>node app.js
ChatBox working on port 3000
Mode:development
C:'Users'Desktop'myapp'node_modules'mongoose'node_modules'mongodb'lib'se
rver.js:228
process.nextTick(function() { throw err; })
^
Error: connect ETIMEDOUT
at exports._errnoException (util.js:746:11)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
这是我的app.js程序
var express = require('express'),
app = express(),
path =require('path'),
cookieParser = require('cookie-parser'),
session = require('express-session'),
config = require('./config/config.js'),
ConnectMongo = require('connect-mongo')(session)
mongoose = require('mongoose').connect(config.dbURL)
app.set('views', path.join(__dirname, 'views'));
app.engine('html', require('hogan-express'));
app.set('view engine' , 'html');
app.use(express.static(path.join(__dirname,'images')));
app.use(cookieParser());
//app.route('/').get(function(req,res,next){
// res.render('index', {title:'Welcome to ChatBox'});
//})
var env = process.env.NODE_ENV || 'development';
if(env ==='development'){
app.use(session({secret:config.sessionSecret,
saveUninitialized:true,
resave:true}))
}
else
{
app.use(session({
secret:config.sessionSecret,
saveUninitialized:true,
resave:true,
store:new ConnectMongo({
url:config.dbURL,
stringify:true
})
}))
}
var userSchema = mongoose.Schema({
username:String,
password:String,
fullname:String
})
var Person = mongoose.model('users',userSchema);
var Kajol= new Person({
username:'Kajol',
password:'kajol_123',
fullname:'Kajol Sakshi'
})
Sunitha.save(function(err){
console.log('done');
})
require('./route/route.js')(express , app);
app.listen(3000,function(){
console.log('ChatBox working on port 3000');
console.log("Mode:" +env);
})
我development.json 这是假的URL,我没有把我的原始URL贴在这里。仅用于格式
{
"dbURL" :"mongodb://chatboxuser:chatbox1234@ds051803.mongolab.com:41603/chatbox",
"sessionSecret":"ALKKLHFDOI7UW98U3209UNFER923YH"
}
从之前发送的错误消息来看,有可能mongoose没有正确编译。通过使用这个页面https://github.com/nodejs/node-gyp
你会注意到在这个页面上node-gyp, nodejs用来将模块编译成本地代码的模块需要一些额外的东西,比如Visual Studio等。看看你是否可以下载这些并按照指示进行设置。完成后,再次安装node-gyp,并重新安装所有依赖项,包括mongoose。
一般来说,这应该作为最后的措施来完成工作。
相关文章:
- 使用优化器在慢速连接上加载main.js时需要js超时
- 如何在自动重新连接超时后重新连接socket.io客户端
- AngularjS到ElasticSearch的连接超时
- 节点.js浏览器响应:连接超时
- 加载资源时出现 OpenTok JS 连接超时问题
- 在 Node 中,创建具有“等待连接”超时的 http 连接的好方法是什么
- 节点.js npm 安装错误连接超时
- NodeJS+Mongoose连接超时
- 如何解决“;连接超时”;错误
- socket.io事件重新连接超时
- Strophe.js客户端连接到服务器,断开连接/超时
- Javascript:如何检测facebook连接超时错误
- WebApi Catch连接超时错误
- 插入数据库(node.js)时Mysql连接超时
- Html5视频慢速连接超时
- Express.js 4.12连接超时上限
- Node.js无法加载网页,连接超时
- 在node.js中运行应用程序时出现连接超时错误
- Ldapjs在一段时间后连接超时
- 仅针对一个特定函数分析连接超时