Goal
I need my backend to push several answers to my client and I need puppeteer to run backend-side. Puppeteer needs some time to work, but has regular intermediate results and should send updates to the client regulary (in total, one request-responses-cycle takes less than 60secs which seems to be the upper limit for GAE).
Underlying GAE Problem:- Websockets do not work with the standard environment.
- Puppeteer does not work with the flex environment.
Main Problem
As a consequence, I re-implemented my code to use server sent events (which is based on http). I expected that to work in standard. It works fine locally. It does not work on production. It will eventually answer the client but only when I close the connection server side and then send everything in one go. It does not regularly update the client. This only happens on GAE, not locally.
What have I tried?
I do flush the sse-response, as otherwise the compression nodejs library leads to a similar behaviour
I also set these headers, esp. X-Accel-Buffering, taken from here:
res.setHeader('Access-Control-Allow-Origin', "*");
res.setHeader("X-Accel-Buffering", "no");
res.setHeader('Cache-Control', 'no-cache');
res.setHeader('Content-Type', 'text/event-stream');
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader('Connection', 'keep-alive');
Question
How can I make server sent events work with nodejs AND puppeteer on GAE? Or, alternatively, has anybody found any way of answering (in either flex or standard or any other way in GAE) ONE client-request (be it http get, sse, websockets) with several server responses spread over time AND have puppeteer running? This google-groups chat both suggests that SSE works and to use Pusher. Is Pusher an alternative for GAE and nodejs with an angular client? If I went through the "pain" (to me, I am low-experience full-stack dev who does not also want to do ops) of doing GAE-flex with a docker image, would that work? Is there some setting I can change, to not "buffer" the respsones server side?