我和我的团队正在Meteor中实施基于服务的架构。
我们有一个前端服务。这只是使用默认的Meteor连接。我们还有许多后端服务(例如聊天,搜索),我们通过DDP.connect(service_url)
通过前端连接到它们。
在前端服务的环境变量中,我们有DISABLE_WEBSOCKETS=1
。我们还将此环境变量设置为其他服务的相同值。
前端在连接到自身时使用长轮询(默认情况下)。但是,当前端尝试连接到其他服务时,不会禁用websockets。并且,DDP 不回到长轮询。
具体来说,它尝试首先进行websocket连接,然后失败,尝试几次XHR请求。冲洗并连续重复。它可以非常快速地完成数百次次。结果,一切都挂了。
WebSocket connection to 'wss://user.example.com/sockjs/884/ll_pzrru/websocket' failed: WebSocket is closed before the connection is established.
XHR finished loading: POST "https://user.example.com/sockjs/121/tmt57ih1/xhr_send".w._start
XHR finished loading: POST "https://user.example.com/sockjs/924/0i0c9_4f/xhr_send".w._start
XHR finished loading: POST "https://user.example.com/sockjs/221/ea72ap33/xhr".
WebSocket connection to 'wss://user.example.com/sockjs/884/ll_pzrru/websocket' failed: WebSocket is closed before the connection is established.
XHR finished loading: POST "https://user.example.com/sockjs/121/tmt57ih1/xhr_send".w._start
XHR finished loading: POST "https://user.example.com/sockjs/924/0i0c9_4f/xhr_send".w._start
XHR finished loading: POST "https://user.example.com/sockjs/221/ea72ap33/xhr".
在使用多个应用时,如何使DDP回退到长轮询?