I am currently working with Server-Sent Events and I am having a strange issue. As the event goes on, through each iteration I am receiving the following error:
ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in
My code for the Server-Event Server Side is as follows:
<?php
require "connect.php";
session_write_close();
header("Content-Type: text/event-stream
");
$savedcount = 0;
while (1) {
// Who's mechanism
$query = $mysqli->query("SOME QUERY");
$rowcount = $query->num_rows;
if ($savedcount != $rowcount) {
// echo stuff
$savedcount = $rowcount; // only echo stuff if there is new content
}
ob_end_flush();
flush();
sleep(2);
}
?>
I do not completely understand buffers. Also, before you assume that this is terrible practice please know that Server-Sent Events are special. This is a similar script that they show on MDN. For this reason I am not exactly sure why I am continuously receiving these errors.
Suggestions?