Meteor 连接超时。未收到DDP心跳信号
我正试图从CSV上传5000多条评论,然后将它们插入到一个集合中 我得到以下信息:Meteor 连接超时。未收到DDP心跳信号,meteor,ddp,Meteor,Ddp,我正试图从CSV上传5000多条评论,然后将它们插入到一个集合中 我得到以下信息: all done dfae22fc33f08cde515ac7452729cf4921d63ebe.js:24 insert failed: MongoError: E11000 duplicate key error index: ag5Uriwu.comments.$_id_ dup key: { : "SuvPB3frrkLs8nErv" } dfae22fc33f08cde515ac7452729cf4
all done dfae22fc33f08cde515ac7452729cf4921d63ebe.js:24
insert failed: MongoError: E11000 duplicate key error index: ag5Uriwu.comments.$_id_ dup key: { : "SuvPB3frrkLs8nErv" } dfae22fc33f08cde515ac7452729cf4921d63ebe.js:1
Connection timeout. No DDP heartbeat received.
手边的剧本:
'click .importComments': function(e) {
var $self = $(e.target);
$self.text("Importing...");
$("#commentsCSV").parse({
worker: true,
config: {
step: function(row) {
var data = row.data;
for (var key in data) {
var obj = data[key];
post = Posts.findOne({legacyId: obj[1]});
var comment = {
// attributes here
};
Comments.insert(comment);
Posts.update(comment.postId, {
$inc: { commentsCount: 1 },
});
}
$self.text("Import Comments");
},
complete: function(results, file) {
console.log("all done");
}
}
});
}
我怎样才能在不发生连接超时错误的情况下实现这一点
在本地,它似乎工作得不错,但在生产(module.io)上,它的结束相当突然 我认为问题不在于DDP,而在于MongoDB。由于MongoDB错误,DDP连接正在超时 您在
\u id
字段上收到重复的密钥错误。\u id
字段由MongoDB自动编制索引,它是唯一的索引,因此同一个值不能在同一个集合中出现两次
您正在上载的CSV中可能有自己的\u id
字段,这意味着Mongo没有生成自己的二进制字段(这保证了唯一性)
因此,我建议从CSV中删除\u id
字段(如果存在)
您也可以尝试使用以下软件包: