1

We are moving our app from Rackspace to Modulus. We have 2 apps configured as microservices using meteorhacks:cluster package. It seems like Meteor Methods (server1 to server2) call is working but Meteor subscription (client2 to server1) is not working. I am trying to figure out if it is a Cross domain request issue.

// https://github.com/meteorhacks/cluster#microservices

//server2/app.js
Cluster.register(process.env.APP_NAME,{endpoint:process.env.ROOT_URL});
mainApp = Cluster.discoverConnection("server1");
Cluster.allowPublicAccess("server1");  


//client2/app.js
mainApp = Cluster.discoverConnection("server1");
ContentLibrary= new Meteor.Collection('content_library',   {connection:mainApp,idGeneration : 'MONGO'});

//client2/home.js
mainApp.subscribe('contentDocuments','all',function(e){
  if(!e)
    doSomething();//Never gets called
});

//server1/publish.js
Meteor.publish("contentDocuments", function(){
 return ContentLibrary.find({});
}

ContentLibrary collection on the client is never populated.

Our apps works on Rackspace as expected.

ilikeopensource
  • 355
  • 2
  • 7

1 Answers1

1

i'm not using meteorhacks:cluster but i am running microservices for my meteor app. it's on DO, so the setup may be different, but here is how i'm doing it.

i'm using reactive-publish to help with server side reactivity

// client ------
/server/lib/ddp-setup.js
ContentLibrary = DDP.connect('10.123.455.332:3000')

/server/publications.js
Content = new Mongo.Collection('content', {connection: ContentLibrary})
Meteor.publish('content', function(opts){
  check(opts, Object)
  this.autorun(()=>{
    let sub = ContentLibrary.subscribe('content', opts)
    if( sub.ready() ){
      return Content.find({})
    }
  })
})

// server1 @ 10.123.455.332:3000 -------

/server/publications.js
Meteor.publish('content', function(opts){
  check(opts, Object)
  // do something with opts...
  return Content.find({})
})

the idea is that your client is only ever talking to it's own server, but the server then talks with all of your other microservices. this affords you the increased security of allowing servers to speak to each other on a private network (as i have my setup with digital ocean).

letting servers talk to each other over the private network is security at its best and the network latency almost zero between servers. setting it up like this also means that you only have to worry about sticky sessions between your client browser and the web-facing app/service.

this may or may not answer your question, but hopefully it will give you some insight into setting up the architecture.

rkstar
  • 1,178
  • 14
  • 27
  • Thank you so much for your response. I agree with security aspect of it. I will give it a try. We have 3 days to launch so I don't want to take out Cluster yet. But I like everything going via server functionality!! . Thanks again. – ilikeopensource Jan 14 '16 at 20:07