问题
Based on the simple implementation of Meteor Cluster MicroServices the doc I have this implementation for 2 services to communicate.
AppUI
export default CLUSTER_DISCOVERY_URL="mongodb://localhost:3000/meteor";
Cluster.connect(CLUSTER_DISCOVERY_URL);
Cluster.register('appui_service');
loggerService = Cluster.discoverConnection('logger_service');
LoggerService
export default CLUSTER_DISCOVERY_URL="mongodb://localhost:3300/meteor";
Cluster.connect(CLUSTER_DISCOVERY_URL);
Cluster.register('logger_service');
loggerService = Cluster.discoverConnection('appui_service');
As it is, AppiUI runs on port 3000, while LoggerService is on port 3300. When I tried, started the servers, I kept on getting this error log.
I20180719-10:17:27.259(1)? Cluster: connecting to 'mongodb' discovery backend
I20180719-10:17:27.260(1)? Cluster: with options: undefined
W20180719-10:17:27.274(1)? (STDERR) /Users/kehindeadeoya/.meteor/packages/meteor-tool/.1.7.0_3.w8zcf.uowlh++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:313
W20180719-10:17:27.274(1)? (STDERR) throw(ex);
W20180719-10:17:27.274(1)? (STDERR) ^
W20180719-10:17:27.275(1)? (STDERR)
W20180719-10:17:27.275(1)? (STDERR) Error: failed to connect to [localhost:27017]
W20180719-10:17:27.275(1)? (STDERR) at exports.ConnectionPool.<anonymous> (/Users/kehindeadeoya/.meteor/packages/meteorhacks_cluster/.1.6.9.y65r.xg1qe3++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/server.js:555:25)
W20180719-10:17:27.275(1)? (STDERR) at emitThree (events.js:136:13)
W20180719-10:17:27.275(1)? (STDERR) at exports.ConnectionPool.emit (events.js:217:7)
W20180719-10:17:27.275(1)? (STDERR) at exports.Connection.<anonymous> (/Users/kehindeadeoya/.meteor/packages/meteorhacks_cluster/.1.6.9.y65r.xg1qe3++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:156:15)
W20180719-10:17:27.276(1)? (STDERR) at emitTwo (events.js:126:13)
W20180719-10:17:27.276(1)? (STDERR) at exports.Connection.emit (events.js:214:7)
W20180719-10:17:27.276(1)? (STDERR) at Socket.<anonymous> (/Users/kehindeadeoya/.meteor/packages/meteorhacks_cluster/.1.6.9.y65r.xg1qe3++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/connection.js:534:10)
W20180719-10:17:27.276(1)? (STDERR) at emitOne (events.js:116:13)
W20180719-10:17:27.276(1)? (STDERR) at Socket.emit (events.js:211:7)
W20180719-10:17:27.277(1)? (STDERR) at emitErrorNT (internal/streams/destroy.js:64:8)
W20180719-10:17:27.277(1)? (STDERR) at _combinedTickCallback (internal/process/next_tick.js:138:11)
W20180719-10:17:27.277(1)? (STDERR) at process._tickDomainCallback (internal/process/next_tick.js:218:9)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.
I don't understand what the discovery backend means. Secondly, I want to use Meteor's default bundled Mongo for this test, not a stand-alone Mongo, what can I do to get pass this error?
来源:https://stackoverflow.com/questions/51419149/using-meteor-cluster-for-microservice