Open

Description
I have an UI app on port 8001 and an app named contract on port 7001. I have 'cluster' installed and working. I have a subscription and insert method defined in 'contract' app.
'contract' server/app.js
Cluster.connect("mongodb://<username>:<passwd>@URL");
var options = {
endpoint: "http://localhost:7001",
balancer: "http://localhost:7001", // optional
uiService: "web" // (optional) read to the end for more info
};
Cluster.register("contracts", options);
var Contracts = new Meteor.Collection('contracts');
Meteor.methods({
addContract: addContract,
findContracts: findContracts
});
Meteor.publish("getContracts", function () {
return Contracts.find({});
});
function addContract(c){
var data = {
id: c.id,
type: c.type
};
Contracts.insert(data);
}
function findContracts(){
var contracts = Contracts.find().fetch();
return contracts;
}
I am accessing the methods from an angular controller in my UI app.
UI app server/app.js
Cluster.connect(mongodb://<username>:<passwd>@URL");
var options = {
endpoint: "http://localhost:8001",
balancer: "http://localhost:8001" // optional
//uiService: "web" // (optional) read to the end for more info
};
Cluster.register("web", options);
Cluster.allowPublicAccess("contracts");
UI app controller code
var contractConn = Cluster.discoverConnection('contracts');
contractConn.subscribe('getContracts');
var SubscribedContracts = new Mongo.Collection('SubscribedContracts', {connection: contractConn});
console.log('status', contractConn.status());
vm.contracts = SubscribedContracts.find({}).count();
contractConn.call("findContracts", function(err, result) {
if(err) {
throw err ;
}
else {
console.log(result);
}
});
This is what is happening:
- I can access methods on the contract server
- I can insert or find contracts using these methods
- My subscription is not working. fetch on the cursor shows 0 and count shows 0
- Status on the connection shows 'connecting'
What am I doing wrong with my subscription?
Sudi
Metadata
Metadata
Assignees
Labels
No labels