How to set Meteor WebSocket port for clients?

落花浮王杯 提交于 2019-12-23 01:34:11

问题


How can I set the port WebSocket will be listening on? I'm trying to deploy Meteor on OpenShift, but there they have a nodejs-proxy server that listen on port 8000 instead 80, and redirect to my Meteor daemon. It is working since a manually created WebSocket object works fine.

I've set ROOT_URL but without success. It appears on the browser as defined bellow:

process.env.ROOT_URL = 'http://' + process.env.OPENSHIFT_APP_DNS + ':8000'

I'm using this quickstart: https://github.com/openshift-quickstart/openshift-meteorjs-quickstart. See file meteorshim.js for reference.

Everything works fine, including long-polling.


回答1:


I struggled with this for a while now and I tried different things. The solution that worked for me in OpenShift was this:

Set the DDP_DEFAULT_CONNECTION_URL variable

//for http
process.env.DDP_DEFAULT_CONNECTION_URL = 'http://' + process.env.OPENSHIFT_APP_DNS + ':8000'
//for ssl
process.env.DDP_DEFAULT_CONNECTION_URL = 'https://' + process.env.OPENSHIFT_APP_DNS + ':8443'

According to this blog post




回答2:


Just use the environmental variable PORT

so I guess:

process.env.PORT = 8000
process.env.ROOT_URL = 'http://' + process.env.OPENSHIFT_APP_DNS

To set websockets on a different port specifically and have meteor run on a different port I'm not too sure this is possible yet.



来源:https://stackoverflow.com/questions/19451428/how-to-set-meteor-websocket-port-for-clients

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!