How to access app hosted on meteor.com by DDP (WebSocket) protocol?
Asked Answered
C

1

9

I have a Meteor app A and another application B, not using Meteor, but making some data exchange with the app A. It works fine when I launch A on a machine in my local network, but when I deploy it on meteor.com hosting it doesn't. Server doesn't reply.

B uses code new WebSocket("ws://" + host + ":3000/websocket") for connection (DDP protocol). But when I change ws to wss it doesn't work any more even with the machine in LAN - it doesn't reply.

I saw that main page of app A when I open it in browser uses URLs like

wss://ddp--6774-{my host name}.meteor.com/sockjs/465/asf0b7da/websocket.

Questions:

  1. How can I make B to use secure WebSocket (wss) for connection?

  2. How can I make connect it to A hosted on {my host name}.meteor.com?

  3. How can force A to reply to requests using fixed URL, for example, ws://{my host name}.meteor.com:3000/websocket ? How can I force it to use ws instead of wss?

  4. Should I specify something in config.js or settings.js?

  5. Is there any way to specify environment variables for meteor.com hosting, for example, DDP_DEFAULT_CONNECTION_URL, NODE_OPTIONS?

Cthrine answered 17/9, 2013 at 18:52 Comment(0)
P
7
  1. The websocket server is handled by sockjs, so as long as you use a standard wss it should 'just work' (see https://github.com/sockjs/sockjs-node). If you're websocket implementation on your client is built to use websockets it should be ok. The atmosphere/meteorite projects use the node-ddp client with secure sockets (there were a couple of issues but I think theyre sorted). (In turn which depends on the faye-websockets library)

  2. I'm not too sure which language you're coding your app B in, but you need to use a DDP client to connect to your server, or you could write one, the DDP spec is fairly open and reversible. There are a couple of DDP implementations out there, some might need to be brought up to date to the pre-1 release spec:

    Additionally you might run into trouble, as you discovered a connection to new WebSocket("ws://" + host + ".meteor.com/websocket") is fruitless, this is because meteor deploy hosting uses a ddp proxy (which is accessed via ddp--xxxx-{my host name}.meteor.com, but the xxxx also always changes when you make a new deployment, you have to access the html file and parse out what the ddp server is or make a note of it every time you deploy your app.

  3. If you connect on port 443 it should be wss. I'm not too sure websockets do redirects. This is a server side thing, so if you're using meteor deploy you wont have control over this yet (perhaps when they release galaxy this might change). Perhaps the force-ssl package might help? Not too sure if it also enforces the websockets part of the connection too, though.

  4. For DDP there aren't any known settings you can specify in the settings

  5. For meteor deploy hosting you can't alter the DDP server to use another one or alter the environmental variables (see https://github.com/oortcloud/unofficial-meteor-faq).

Keep in mind meteor deploy hosting is very young & the guys who make meteor still haven't released their galaxy solution so this might all change in the future.

Btw sorry about the layout/spacing, I can't get the hang of this markdown thing.

Phosphoric answered 17/9, 2013 at 22:33 Comment(2)
It was just wrong port. Works on port 443 fine. Shame for me.Cthrine
I can't connect to my app that's deployed on Heroku. I've tried all the urls listed: wss://<app>.com/websocket wss://<app>.com/websocket:443 wss://<app>.com:443 wss://<app>.com/ ws://<app>.com ws://<app>.com/websocket ws://<app>.com/websocket:443 ws://<app>.com:443/websocket wss://<app>.com:443/websocket ws://<app>.com:3000/websocket wss://<app>.com:3000/websocket ws://<app>.com:3000 wss://<app>.com:3000Halfsole

© 2022 - 2024 — McMap. All rights reserved.