Open bicdibuss opened 6 years ago
Are you more open-minded than you mean?
@ionurboz :) @bicdibuss maybe Same-Origin-Policy ?
Im building a chat using this script on localhost all works good, but when I moove scrips to the server it works only about 10 minutes then in console of browser I see 504 error and script stop work. After reloading page it works again the same time.
What your application name? Maybe the localhost application blocked more live connection?
On localhost it works good. On server even example script got error. May be I need some configs of nginx or php?
Maybe this is the root of the problem max_execution_time
.
php.ini edit
max_execution_time
.
Defaults:
max_execution_time | "30"
try repeating the same things 30 seconds later without refreshing the page
if you do not find a solution
usleep ();
investigate
I have set max_execution_time=3600 but it dosent help server.php?timestamp=1527239428 504 (Gateway Time-out)
it's probably a 600 seconds limit on nginx side :)
I am getting 504 error from nginx too when it reaches its time limit on how long it would wait for a response from php-fpm.
What's the best practice?
For now I put a time limit into the PHP script, so it would return a json object before the nginx time limit kicks in, then javascript would send another request to the server.
IE
$start_time = time();
$time_limit = 60; // set this to be less than the nginx time limit
// main loop
while (true) {
...
$time_lapsed = time() - $start_time;
if ($time_lapsed >= $time_limit || $last_ajax_call == null || $last_change_in_data_file > $last_ajax_call) {
...
// leave this loop step
break;
...
By doing this it is combining short-polling and long-polling... but not much choice when you can't control nginx limits from PHP I guess?
I have a php5.6 nginx 2GB Ram on my server. On localhost it works good. What the problem can it be?