如何通过DDP(WebSocket)协议访问meteor.com上托管的应用程序? [英] How to access app hosted on meteor.com by DDP (WebSocket) protocol?

查看:256
本文介绍了如何通过DDP(WebSocket)协议访问meteor.com上托管的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有流星应用 A 和另一个应用 B ,不使用Meteor,但与应用 A 进行一些数据交换。当我在本地网络中的计算机上启动 A 时,它工作正常,但是当我在meteor.com托管它时,它没有。服务器不回复。

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 使用代码新的WebSocket(ws:/ /+ host +:3000 / websocket)用于连接(DDP协议)。
但是当我将ws更改为wss时,即使使用局域网中的机器它也不再工作 - 它不会回复。

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.

我看到了主要信息应用页面 A 当我在浏览器中打开它时使用的网址如

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

wss:/ / ddp - 6774- {我的主机名} .meteor.com / sockjs / 465 / asf0b7da / websocket

问题:


  1. 如何制作 B 使用安全WebSocket(wss)进行连接?

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

如何将其连接到 {托管在{my host name} .meteor.com上?

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

如何强制 A 使用固定URL回复请求,例如 ws:// {我的主机名} .meteor.com:3000 / websocket ?如何强制它使用ws而不是wss?

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?

我应该在config.js或settings.js中指定一些内容吗?

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

有没有办法为meteor.com托管指定环境变量,例如DDP_DEFAULT_CONNECTION_URL,NODE_OPTIONS?

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


推荐答案


  1. websocket服务器由sockjs处理,所以只要你使用一个标准的应该正常工作(参见 https://github.com/sockjs/sockjs-node )。如果您的客户端上的websocket实现是为了使用websockets而构建的,那么它应该没问题。大气/陨石项目使用带有安全套接字的node-ddp客户端(有几个问题,但我认为它们已经排序)。 (反过来取决于 faye-websockets库

  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)

我不太确定您正在编写应用程序B的语言,但是您需要使用DDP客户端连接到您的服务器,或者您可以编写一个,DDP规范相当打开reversible
有几个DDP实现,有些可能需要更新到1之前版本规范:

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)

此外,您可能遇到麻烦,因为你发现了与的连接新的WebSocket(ws://+ host +。meteor.com / websocket)是徒劳的,这是因为meteor deplo y hosting使用ddp代理(可通过 ddp-xxxx- {my host name} .meteor.com 访问,但 xxxx 在您进行新部署时也总是会更改,您必须访问html文件并解析ddp服务器的内容,或在每次部署应用程序时记下它。

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.

如果你在端口443上连接它应该是wss。我不太确定websockets会重定向。这是服务器方面的事情,所以如果你使用meteor部署你还不能控制它(也许当它们释放galaxy时,这可能会改变)。也许 force-ssl 包可能有帮助吗?但是,不太确定它是否也强制执行连接的websockets部分。

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.

对于DDP,您可以在设置中指定任何已知设置

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

对于meteor部署托管,您无法更改DDP服务器以使用其他服务器或更改环境变量(请参阅https://github.com/oortcloud/unofficial-meteor-faq )。

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).

请记住meteor部署托管是非常年轻的&制造流星的人仍然没有发布他们的星系解决方案,所以这可能会在未来发生变化。

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.

这篇关于如何通过DDP(WebSocket)协议访问meteor.com上托管的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆