Connect two Meteor applications using DDP

后端 未结 1 1008

I have two applications that I need to synchronise. One of them will receive data from users and the other will display the data. Both applications will work on different se

相关标签:
1条回答
  • 2020-12-08 06:06

    I got a clue from this question How to properly use Meteor.connect() to connect with another Meteor server. I missed it because it was about the old Meteor.connect() that changed to DDP.connect().

    This worked on client and server

    var remote = DDP.connect('http://server1.com/');
    Items = new Meteor.Collection('items', remote); 
    
    remote.subscribe('items', function() {
      var items = Items.find();
      console.log(items.count());  // get 1         
    });
    

    Now I can watch for changes in application 1 from application 2 using Items.find().observe()

    Warning

    There is a bug on Meteor that will stop the connection between applications:

    • https://github.com/meteor/meteor/issues/1543
    • DDP between two servers doesn't reconnect

    Update

    The bug was solved

    Update 2

    This is a sample project tested with Meteor 0.6.6.2 https://github.com/camilosw/ddp-servers-test

    0 讨论(0)
提交回复
热议问题