Server Sent Events With Codeigniter 4 |
I am trying to update the progress of a long running php script on frontend using server sent events.
But am only receiving first few eventstreams and thereafter there is error. I am Sharing code below; Html View: Code: <a href="#" onclick="startScraping()" >START SCRAPING</a> Home Controller: PHP Code: <?php namespace App\Controllers; Common.php file: PHP Code: function sendMsg($id, $message, $progress) Here this loop is not fully executed. I am only receiving first few rows as response. There after am getting this error id:1608816937 data:{"message":"1 row(s) Processed.","progress":0} <br /> <b>Fatal error</b>: Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at /var/www/webScraper/app/Common.php:130) in /var/www/webScraper/system/Debug/Exceptions.php:164 Stack trace: #0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'Cannot modify h...', '/var/www/webScr...', 164, Array) #1 /var/www/webScraper/system/Debug/Exceptions.php(164): header('HTTP/1.1 500 In...', true, 500) #2 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException)) #3 {main} thrown in <b>/var/www/webScraper/system/Debug/Exceptions.php</b> on line <b>164</b><br /> <br /> <b>Fatal error</b>: Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at /var/www/webScraper/app/Common.php:130) in /var/www/webScraper/system/Debug/Exceptions.php:164 Stack trace: #0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'Cannot modify h...', '/var/www/webScr...', 164, Array) #1 /var/www/webScraper/system/Debug/Exceptions.php(164): header('HTTP/1.1 500 In...', true, 500) #2 /var/www/webScraper/system/Debug/Exceptions.php(224): CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException)) #3 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler() #4 {main} thrown in <b>/var/www/webScraper/system/Debug/Exceptions.php</b> on line <b>164</b><br /> What am i doing wrong? |
Messages In This Thread |
Server Sent Events With Codeigniter 4 - by midhunlalkc - 12-24-2020, 06:42 AM
RE: Server Sent Events With Codeigniter 4 - by InsiteFX - 12-24-2020, 01:14 PM
RE: Server Sent Events With Codeigniter 4 - by includebeer - 12-24-2020, 01:30 PM
RE: Server Sent Events With Codeigniter 4 - by midhunlalkc - 12-25-2020, 11:32 PM
|