3

Is there any way of creating multiple meteor clients on one server? What I mean is having multiple, distinct, client applications that all communicate with the same server? So, a data change at www.mainapp.com will show up in www.companionapp.com and vice versa.

Thanks.

nicholas
  • 14,184
  • 22
  • 82
  • 138

2 Answers2

0

Is there any way of creating multiple meteor clients on one server?

Yes, you can host them behind a reverse proxy like nginx.

What I mean is having multiple, distinct, client applications that all communicate with the same server? So, a data change at www.mainapp.com will show up in www.companionapp.com and vice versa.

Yes, as long as all of the apps are started with the name MONGO_URL, then they will share the same database (and therefore simultaneously reflect its changes).

Community
  • 1
  • 1
David Weldon
  • 63,632
  • 11
  • 148
  • 146
0

You can have multiple distinct applications that use the same DDP connection so that data is shared reactively across applications.

To share a DDP connection:

Main App (running on port 3000):

Posts = new Meteor.Collection("posts");

if(Meteor.isServer){
    Meteor.publish("posts", function(){
        return Posts.find({});
    });
}

if (Meteor.isClient){
    Posts.subscribe("posts");
}

Companion App (running on port 3030):

var conn = DDP.connect("http://localhost:3000");
Pictures = new Meteor.Collection("pictures", conn);

if(Meteor.isClient){
    conn.subscribe("posts");
}

If you're running both apps on the same box you'll need to specify different ports for each app:

meteor --port 3030

Server 2 Server DDP A pretty entertaining youtube video from Alan Shaw, that this answer is based off.

And I'd recommend reading Meteorhacks' Introduction to DDP

NOTE: DDP connections only work through websockets, so if you have a proxy in between you'll run into issues