DDP Publications


I have managed to get 2 apps connect via DDP, but I am a little unsure on how to publish data from the origin server.

Here is what I am trying on the client:

  Meteor.remoteConnection = DDP.connect('http://localhost:3030');
  this.subscribe('templatePublication', {connection:Meteor.remoteConnection});

That is supposedly calling a publication on the origin server. It is not throwing any errors, but at the same time it is not producing any documents, which it should as the publication is a simple Collection.find({});

Just curious if there is something I am missing…


Check out the documentation for DDP.connect. Long story short it returns an object which has subscribe method which you can use to subscribe to remote publication. So in your case you can write your code as follows:

  Meteor.remoteConnection = DDP.connect('http://localhost:3030');

However it’s better to assign remote connection to a new variable, not Meteor.remoteConnection.


For me at least this approach still didnt seem to want to work; however, I did find a solution that worked for me:

import { DDP } from 'meteor/ddp-client'

var remote = DDP.connect('http://localhost:3030/');
Templates = new Meteor.Collection('templates', remote);


  listTemplates: ()=>{
    return Templates.find();