My team and I are implementing a services based architecture in Meteor.
We have a frontend service. This simply uses the default Meteor connection. We also have a number of backend services (e.g. Chat, Search) and we connect to them via the frontend via DDP.connect(service_url)
.
In the environment variables for the frontend service, we have DISABLE_WEBSOCKETS=1
. We also set this environment variable to the same value for the other services.
The frontend uses long polling just fine when connecting to itself (by default). However, when the frontend attempts to connect to the other services, the websockets are not disabled. And, DDP is not falling back to long polling.
Specifically, it tries to make the websocket connection first, fails at that, tries some XHR requests a few times. Rinse and repeat continuously. It does this hundreds of times and extremely quickly. As a result, everything just hangs.
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".
How do we make DDP fallback to long-polling when using multiple apps?