I have a Chrome container (deployed using this Dockerfile) that renders pages on request from an App container.
The basic flow is:
- App sends an http request to Chrome and in response receives a websocket url to use (e.g.
ws://chrome.example.com:9222/devtools/browser/13400ef6-648b-4618-8e4c-b5c73db2a122
) - App then uses that websocket url to communicate further with Chrome, and to receive the rendered page. I am using the puppeteer library to connect to and communicate with the Chrome instance, using
puppeteer.connect({ browserWSEndpoint: webSocketUrl })
;
For a single Chrome container this works really well.
But I'm trying to scale things up to have multiple Chrome containers in a Docker swarm.
The problem is, I think, that the websocket url received by App is specific to the instance running in that particular Chrome container, so when it is used by App (and where there are now multiple Chrome containers), the websocket requests from App will not necessarily be routed to the right Chrome container.
What is the best way of dealing with this?