Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server Sent Events(SSE) in Google App Engine

Does GAE support Server Sent Events (SSE)?

I tried using SSE but it did not work ,so I switched to Channel API. But still is it possible to implement SSE in GAE ?

like image 222
DoOrDoNot Avatar asked Oct 19 '22 15:10

DoOrDoNot


1 Answers

I've been trying like crazy to pull this one off but the GAE response is being buffered and compressed.

I'll be very happy if someone has an idea how to write the code/headers so the php file is streamed.

FYI, these are the headers I'm using:

header("Content-Type: text/event-stream; charset=utf-8");
header("Accept-Encoding: identity");
header("Cache-Control: no-cache");
header("Access-Control-Allow-Origin: https://mail.google.com");
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"');

[UPDATE]

From: http://grokbase.com/t/gg/google-appengine/15623azjjf/server-sent-events-using-channels-api

What this means in practice is that your stream will not be "keep-alive" and will close each time one response is sent. Or, if you implement your server-sent event code server-side as most people do, it will buffer up all of its responses and finally send them all only when it terminates.

Please read: https://cloud.google.com/appengine/docs/php/requests#PHP_Responses

Resume: there is no way to do SSE using GAE.

like image 161
Alberto Alexander Rodriguez Avatar answered Oct 23 '22 11:10

Alberto Alexander Rodriguez