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:
How can I make B
to use secure WebSocket (wss) for connection?
How can I make connect it to A
hosted on {my host name}.meteor.com?
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?
Should I specify something in config.js or settings.js?
Is there any way to specify environment variables for meteor.com hosting, for example, DDP_DEFAULT_CONNECTION_URL, NODE_OPTIONS?
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)
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:
- Java (https://github.com/kutrumbo/java-ddp-client)
- Ruby (https://github.com/tmeasday/ruby-ddp-client)
- NodeJS (https://github.com/oortcloud/node-ddp-client) - Up to date
- Objective-C (https://github.com/boundsj/ObjectiveDDP)
- .NET (C#/VB.NET) (https://github.com/sonyarouje/DDPClient.NET)
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.
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.
For DDP there aren't any known settings you can specify in the settings
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.