Error: Error setting TTL index on collection : sessions
Error: Error setting TTL index on collection : sessions
一、步骤一:
这个问题一般是直接升级 mongodb
和connect-mongo
的版本为最新就可以了。
(注:记得一定要删除掉node_module再重新安装,因为你在package.json中对引用的模块进行改变版本号,也不会更新的,需要删除掉后再重新下载安装,自己就是在这步坑了~~ - -!)
二、步骤二:
如果上面的步骤无法解决问题,那么就进行该步骤:
检查express 配置session中间件的时候,是否配置正确。
因为自己就是因为配置不正确才导致报错的,我当时是在配置session的时候,加了点要求,需要将session信息保存到mongo数据库中去,而不是只是保存在内存中。正是因为配置要将session信息保存到数据库中去的配置错了。
如果不需要保存session信息到mongo数据库中,而只是存储在内存中的话,那么可以照API上的配置进行配置:
var session = require('express-session');
.....
/**
* secret 用来防止篡改 cookie,
* key 的值为 cookie 的名字,
* 通过设置 cookie 的 maxAge 值设定 cookie 的生存期,
* 这里我们设置 cookie 的生存期为 30 天.
* resave : 是指每次请求都重新设置session cookie,假设你的cookie是10分钟过期,每次请求都会再设置10分钟
* saveUnitialized 是指无论有没有session cookie,每次请求都设置个session cookie,默认给个标识为connect.sid
*/ app.use(session({ secret: 'myblog', key: 'blog', cookie: {maxAge: * * * * },//30 day resave:false, saveUninitialized: true }));
如果需要存储到mongo数据库中去,那么可以按照下面的方法进行配置:
因为我们在这里使用的 connect-mongo
来保存session信息到mongo数据库中去的。
所以,我们可以参考: https://www.npmjs.com/package/connect-mongo
app.use(session({
secret: settings.cookieSecret
, key: settings.db
, cookie: {maxAge: * * * * }//30 day
, resave: false
, saveUninitialized: true
,store: new MongoStore({
//url: 'mongodb://localhost:27017/blog'
db:settings.db
,host:settings.host
,port:settings.port
})
}));
Error: Error setting TTL index on collection : sessions的更多相关文章
- 表结构变更后出现的ERROR OGG-01161 Bad column index (88)
2014-07-31 09:38:31 ERROR OGG-01668 PROCESS ABENDING. 2014-07-31 09:38:31 ERROR OGG-01161 Bad column ...
- Module Error (from ./node_modules/eslint-loader/index.js):解决办法
vue启动项目报如下错误: Failed to compile. ./src/components/Vcontent.vue Module Error (from ./node_modules/esl ...
- git 出现 error: bad signature fatal: index file corrupt
一次大改版,提交了很多代码,但再次提交提交不了,也拉不下来仓库的代码 提示error bad signature fatal: index file corrupt 在项目有.git这同级打开Git ...
- gcc 错误:Fatal error error writing to tmp No space left on device
在使用gcc make时报错:Fatal error error writing to tmp No space left on device finiteVolume/ddtSchemes/Eule ...
- ERROR: Error in Log_event::read_log_event(): 'read error', data_len: 438, event_type: 2
分析从库1062问题,解析从库binlog日志,报错如下 [root@xxxdb0402 tmp]# mysqlbinlog mysql-bin.004271 > 4.log ERROR: Er ...
- react native中一次错误排查 Error:Error: Duplicate resources
最近一直在使用react native中,遇到了很多的坑,同时也学习到了一些移动端的开发经验. 今天在做一个打包的测试时,遇到了一个问题,打包过程中报错“Error:Error: Duplicate ...
- 解决:[ERROR] Error executing Maven. [ERROR] 1 problem was encountered while building the effective set
1. 报错如下: [ERROR] Error executing Maven. [ERROR] 1 problem was encountered while building the effecti ...
- Spring mvc 中使用ftl引用共通文件出错 FreeMarker template error: Error reading included file "/WEB-INF/ftl/common/errormessage.ftl"
初次接触spring mvc,想做一个小的练习项目,结果在ftl文件中引用其它的共通ftl文件时出错.
- error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCom ...
随机推荐
- android rectF
new Rect(left , top, right , bottom) 这个构造方法需要四个参数这四个参数 指明了什么位置 ?我们就来解释怎么画 这个 矩形 这四个 参数 分别代表的意思是:left ...
- JSP网站开发基础总结《一》
经过JAVASE的学习相信大家对JAVA已经不再陌生,那么JAVA都可以干什么呢?做算法.应用程序.网站开发都可以,从今天开始为大家奉上JAVAEE之JSP动态网站开发基础总结. 既然是动态网站开发, ...
- mysql replication principle--转
原文地址:http://www.codeweblog.com/mysql-replication-principle/ 1, the replication process Mysql replica ...
- 自己的JS框架--Amy框架。
这是我根据司徒正美<JavaScript框架设计>一书然后百度了很多东西之后自己写的一个JS框架,满足了司徒正美文中的种子模块部分,包含了命名空间.对象扩展.数组化.类型判断.选择器.多库 ...
- 在Spring Boot中使用Https
本文介绍如何在Spring Boot中,使用Https提供服务,并将Http请求自动重定向到Https. Https证书 巧妇难为无米之炊,开始的开始,要先取得Https证书.你可以向证书机构申请证书 ...
- 转载:java程序员如何拿到2万月薪
作者:匿名用户链接:https://www.zhihu.com/question/39890405/answer/83676977来源:知乎 著作权归作者所有.商业转载请联系作者获得授权,非商业转载请 ...
- Theano入门神经网络(二) 实现一个XOR门
与非门的图片如下 示意图 详细解释: 1 定义变量的代码,包括了输入.权值.输出等.其中激活函数采用的是sigmod函数 # -*- coding: utf-8 -*- __author__ = 'A ...
- Canny边缘检测算法原理及C语言实现详解
Canny算子是John Canny在1986年提出的,那年老大爷才28岁,该文章发表在PAMI顶级期刊上的(1986. A computational approach to edge detect ...
- jQuery 3.1 API中文文档
jQuery 3.1 API中文文档 一.核心 1.1 核心函数 jQuery([selector,[context]]) 接收一个包含 CSS 选择器的字符串,然后用这个字符串去匹配一组元素. jQ ...
- elk收集分析nginx access日志
elk收集分析nginx access日志 首先elk的搭建按照这篇文章使用elk+redis搭建nginx日志分析平台说的,使用redis的push和pop做队列,然后有个logstash_inde ...