当在指定端口上接收到 ZeroMQ 消息时,以下 Meteor 代码片段会停止。但是,如果我更改remove
为find
,它可以正常工作。 insert
操作也失败。请注意,insert
如果remove
在回调之外运行,例如在部件下方,则成功pull.on
。
var Components = new Meteor.Collection("components");
function handle_message(msg) {
console.log("pull on message" + msg);
Components.remove();
}
if (Meteor.isServer) {
Meteor.startup(function () {
var zmq = Meteor.require("zmq");
var pull = zmq.socket("pull");
pull.bind("tcp://127.0.0.1:7000", function(data) {
console.log("Connection received from ZMQ");
});
pull.on('message', handle_message);
});
}
例外是:
W20130827-21:36:21.800(0)? (STDERR) packages/mongo-livedata.js:1640
W20130827-21:36:21.802(0)? (STDERR) throw e;
W20130827-21:36:21.803(0)? (STDERR) ^
W20130827-21:36:21.843(0)? (STDERR) TypeError: Cannot read property '_meteor_dynamics' of undefined
W20130827-21:36:21.843(0)? (STDERR) at Object.Meteor.bindEnvironment (packages/meteor/dynamics_nodejs.js:55)
W20130827-21:36:21.845(0)? (STDERR) at _.extend._wrapAsync (packages/meteor/helpers.js:108)
W20130827-21:36:21.845(0)? (STDERR) at _.each.MongoConnection.(anonymous function) [as remove] (packages/mongo-livedata/mongo_driver.js:340)
W20130827-21:36:21.846(0)? (STDERR) at _.each.Meteor.Collection.(anonymous function) [as remove] (packages/mongo-livedata/collection.js:406)
W20130827-21:36:21.846(0)? (STDERR) at Socket.handle_message (app/web.js:5:16)
W20130827-21:36:21.847(0)? (STDERR) at Socket.EventEmitter.emit (events.js:96:17)
W20130827-21:36:21.847(0)? (STDERR) at Socket._flush._flushing (/home/vagrant/.meteorite/packages/npm/arunoda/meteor-npm/ad83acff83385d5ea05997c8bbc2d7493ba4c04e/.build/npm/node_modules/zmq/lib/index.js:358:25)
W20130827-21:36:21.852(0)? (STDERR) at global.setImmediate (/home/vagrant/.meteorite/packages/npm/arunoda/meteor-npm/ad83acff83385d5ea05997c8bbc2d7493ba4c04e/.build/npm/node_modules/zmq/node_modules/set-immediate/setImmediate.js:15:9)
W20130827-21:36:21.852(0)? (STDERR) at process.startup.processNextTick.process._tickCallback (node.js:245:9)
有人有想法么?谢谢!