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入门(十七)Android多线程
原文链接:http://www.orlion.ga/670/ 一.在子线程中更新UI Android中不允许在子线程中更新UI,只能在主线程中更新,但是我们有时候必须在子线程中执行一些耗时的任务,然后 ...
- JavaScript垃圾回收(二)——垃圾回收算法
一.引用计数(Reference Counting)算法 Internet Explorer 8以下的DOM和BOM使用COM组件所以是引用计数来为DOM对象处理内存,引用计数的含义是跟踪记录每个值被 ...
- SQLServer学习笔记系列6
一.写在前面的话 时间是我们每个人都特别熟悉的,但是到底它是什么,用什么来衡量,可能很多人会愣在那里.时间可以见证一切,也可以消磨一切,那些过往的点点滴滴可思可忆.回想往年清明节过后,在家乡的晚上总能 ...
- 在Android中实现service动态更新UI界面
之前曾介绍过Android的UI设计与后台线程交互,据Android API的介绍,service一般是在后台运行的,没有界面的.那么如何实现service动态更新UI界面呢?案例:通过service ...
- SQL Server代理(4/12):配置数据库邮件
SQL Server代理是所有实时数据库的核心.代理有很多不明显的用法,因此系统的知识,对于开发人员还是DBA都是有用的.这系列文章会通俗介绍它的很多用法. 在以前的文章里我们看到,SQL Serve ...
- Git学习笔记(四)
一.忽略特殊文件 在Git工作区的根目录下创建一个特殊的.gitignore文件,然后把要忽略的文件名填进去,Git就会自动忽略这些文件. 不需要从头写.gitignore文件,GitHub已经为我们 ...
- MVC中的默认Model绑定者DefaultModelBinder
一.题外话 接续上一篇: MVC中Action参数绑定的过程 public IModelBinder DefaultBinder { get { if (this._defaultBinder == ...
- noip模拟赛 纸壳子
Task 1.纸壳子(box.pas/box.c/box.cpp) [题目描述] Mcx是一个有轻度洁癖的小朋友.有一天,当他沉溺于数学卷子难以自拔的时候,恍惚间想起在自己当初学习概率的时候准备的一堆 ...
- LeetCode - 52. N-Queens II
52. N-Queens II Problem's Link --------------------------------------------------------------------- ...
- Ajax 学习 - 基础学习
<AJax - Async Javascript and xml - 异步的JavaScript和XML> 一.基础认识 AJax技术的目的:实现页面无刷新数据动态更改 优点: + 不需 ...