簡體   English   中英

模數流星微服務訂閱不起作用

[英]Modulus Meteor Microservices Subscriptions not working

我們正在將我們的應用程序從Rackspace遷移到Modulus。 我們使用meteorhacks:cluster軟件包將2個應用程序配置為微服務。 看來Meteor方法(從server1到server2)的調用正在工作,但Meteor訂閱(從client2到server1的電話)卻無法工作。 我試圖弄清楚這是否是跨域請求問題。

// 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集合。

我們的應用程序可以按預期在Rackspace上運行。

我沒有使用meteorhacks:cluster,但我正在為我的流星應用程序運行微服務。 它在做,所以設置可能會有所不同,但是這就是我的做法。

我正在使用反應式發布來幫助服務器端反應

// 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({})
})

這樣的想法是,您的客戶端只與它自己的服務器通信,但是服務器隨后會與您的所有其他微服務通信。 這為您提供了更高的安全性,允許服務器在專用網絡上相互通信(因為我已經在Digital Ocean上進行了設置)。

讓服務器通過專用網絡相互通信是最好的安全性,服務器之間的網絡延遲幾乎為零。 像這樣進行設置也意味着您只需要擔心客戶端瀏覽器和面向Web的應用程序/服務之間的會話阻塞。

這可能會回答您的問題,也可能不會回答您的問題,但希望它能使您對設置體系結構有一些了解。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM