jquery — закрытие / сбой php-cgi nginx из-за вызовов ajax

Я только что настроил nginx на своем веб-сайте, и когда посетители посещают php-cgi.exe и веб-сайт работает очень медленно, и я не уверен, загружается ли он вообще. nginx.exe все еще работает как сервис, насколько я вижу. Ниже приведен мой журнал ошибок (каждый раз один и тот же тип сообщений), я думаю, что они связаны с вызовами ajax, я очень озадачен, почему это происходит, и как я могу это исправить.

Ошибки:

    2015/09/27 09:42:58 [error] 800#3404: *334 WSASend() failed (10054: An existing connection was forcibly closed by the remote host) while sending request to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443372147307 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/27 09:42:58 [error] 800#3404: *311 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443372147305 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/27 09:42:58 [error] 800#3404: *305 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443372147304 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/27 09:42:58 [error] 800#3404: *310 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443372147306 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/27 09:42:58 [error] 800#3404: *324 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443372147303 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"

После закрытия php-cgi.exe я начинаю получать эти ошибки

2015/09/27 09:43:58 [error] 800#3404: *323 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443372147308 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/27 09:43:58 [error] 800#3404: *334 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443372147309 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/27 09:43:58 [error] 800#3404: *324 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443372147310 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/27 09:43:58 [error] 800#3404: *305 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443372147311 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/27 09:43:58 [error] 800#3404: *311 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443372147312 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/27 09:43:58 [error] 800#3404: *310 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443372147313 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"

Остановка и запуск nginx исправляет это в течение еще 5 минут, пока не будет выполнено около 15 вызовов ajax, пока он снова не выйдет из строя !!? Ajax-вызов вызывается раз в 1 секунду для обновления чата.

Ajax:

function loadMessages()
{
$.ajax({

type: "GET",
url: '<?php echo $config['website']['url']; ?>/assets/hk/ajax/staff_messages.php',
success: function(data) {

if (staffContent != data)
{
var div = document.getElementById('staffmessagesArea');
div.innerHTML = data;
staffContent = data;
updateScroll();
}
}

});
setTimeout(loadMessages,1000);
}

Страница вызова Ajax:

<?php
require_once '../../other/connection.php';
global $pdo;

$stmt = $pdo->prepare("SELECT * FROM `craft_hk_messages` ORDER BY `When`");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row)
{
if ($row['Sender'] == $_SESSION['user']['username'])
{
echo '<div class="col-md-12"><div style="height:40px;background-color:#B5B5B5;padding:14px;padding-top:10px;border-radius:4px;color:white;float:right;margin-bottom:20px;">' . $row['Message'] . '</div><br></div>';
}
else
{
$figure = "https://game.boon.pw/habbo-imaging/avatarimage.php?figure=".$_SESSION['user']['look']."&action=wav&direction=2&head_direction=3&gesture=sml&size=m&headonly=1";
echo '<div class="col-md-2" style="min-height:50px !important;
background-image:url(\''; echo $figure . '\');background-size: 50px 50px;background-repeat:no-repeat;">
</div><div class="col-md-10" style="margin-left:-60px;"><div style="border-radius:4px;height:40px;background-color:#0094FF;padding:14px;padding-top:10px;color:white;width: auto;float:left;
margin-bottom:20px;

position: relative;">'.$row['Sender'].': ' . $row['Message'] . '</div></div>';
}
}
?>
</thead>
<tbody>
</tbody>
</table>

Конфигурация Nginx:

worker_processes  4;  # 2 * Number of CPUs

events {
worker_connections  19000;  # It's the key to high performance - have a lot of connections available
}

worker_rlimit_nofile    20000;  # Each connection needs a filehandle (or 2 if you are proxying)


# Total amount of users you can serve = worker_processes * worker_connections


http {
include       mime.types;
default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  15;

#gzip  on;

server {
listen       80;
server_name  localhost;

#charset koi8-r;

#access_log  logs/host.access.log  main;



location / {
rewrite ^/(|/)$ /index.php?page=$1;
rewrite ^/([a-zA-Z0-9_-]+)(|/)$ /index.php?page=$1;
rewrite ^/(.*).htm$ /$1.php;
}

#error_page  404              /404.html;

# redirect server error pages to the static page /404.php
#
error_page   500 502 503 504  /404.php;
location = /404.php {
root   html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#    proxy_pass   http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
root           html;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_read_timeout 60000s;
fastcgi_param  SCRIPT_FILENAME  C:/nginx/html/$fastcgi_script_name;
include        fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#    deny  all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}


# HTTPS server
#
#server {
#    listen       443 ssl;
#    server_name  localhost;

#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;
#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers  on;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

}

Вызовы ajax продолжают выполняться даже при закрытии php-cgi, но вы не можете перезагрузить его, так как веб-сайт будет отображаться как автономный.

edit4 обновление журнала:

2015/09/28 11:40:27 [emerg] 2280#948: bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
2015/09/28 11:43:46 [error] 2612#2276: *4 CreateFile() "C:\nginx/html/index" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /index HTTP/1.1", host: "158.69.21.193"2015/09/28 11:43:46 [error] 2612#2276: *4 CreateFile() "C:\nginx/html/favicon.ico" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "158.69.21.193", referrer: "http://158.69.21.193/index"2015/09/28 11:43:53 [error] 2612#2276: *4 CreateFile() "C:\nginx/html/starter-template.css" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /starter-template.css HTTP/1.1", host: "158.69.21.193", referrer: "http://158.69.21.193/index.php?page=index"2015/09/28 11:45:10 [error] 1712#2324: *1 CreateFile() "C:\nginx/html/starter-template.css" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /starter-template.css HTTP/1.1", host: "158.69.21.193", referrer: "http://158.69.21.193/index"2015/09/28 11:45:21 [error] 1712#2324: *1 CreateFile() "C:\nginx/html/assets/website/images/bg_hotel.out.png" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/website/images/bg_hotel.out.png HTTP/1.1", host: "158.69.21.193", referrer: "http://158.69.21.193/home"2015/09/28 11:45:36 [error] 1712#2324: *2 CreateFile() "C:\nginx/html/assets/website/images/bg_hotel.out.png" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/website/images/bg_hotel.out.png HTTP/1.1", host: "158.69.21.193", referrer: "http://158.69.21.193/account"2015/09/28 11:46:22 [error] 1712#2324: *1 CreateFile() "C:\nginx/html/hk/index" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /hk/index HTTP/1.1", host: "158.69.21.193"2015/09/28 11:47:08 [error] 1712#2324: *16 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443465991116 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:47:08 [error] 1712#2324: *16 CreateFile() "C:\nginx/html/50x.html" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443465991116 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:47:08 [error] 1712#2324: *39 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443465991119 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:47:08 [error] 1712#2324: *39 CreateFile() "C:\nginx/html/50x.html" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443465991119 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:47:08 [error] 1712#2324: *1 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443465991117 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:47:08 [error] 1712#2324: *1 CreateFile() "C:\nginx/html/50x.html" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443465991117 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:47:08 [error] 1712#2324: *27 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443465991118 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:47:08 [error] 1712#2324: *27 CreateFile() "C:\nginx/html/50x.html" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443465991118 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:47:08 [error] 1712#2324: *2 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443465991120 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:47:08 [error] 1712#2324: *2 CreateFile() "C:\nginx/html/50x.html" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443465991120 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:48:08 [error] 1712#2324: *40 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443465991121 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:48:08 [error] 1712#2324: *40 CreateFile() "C:\nginx/html/50x.html" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443465991121 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:48:08 [error] 1712#2324: *16 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443465991122 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:48:08 [error] 1712#2324: *16 CreateFile() "C:\nginx/html/50x.html" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443465991122 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:48:08 [error] 1712#2324: *39 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443465991123 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:48:08 [error] 1712#2324: *39 CreateFile() "C:\nginx/html/50x.html" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443465991123 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:48:08 [error] 1712#2324: *517 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443465991124 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:48:08 [error] 1712#2324: *517 CreateFile() "C:\nginx/html/50x.html" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443465991124 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:48:08 [error] 1712#2324: *27 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443465991125 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:48:08 [error] 1712#2324: *27 CreateFile() "C:\nginx/html/50x.html" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/recent_logins.php?_=1443465991125 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:48:08 [error] 1712#2324: *2 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443465991126 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"2015/09/28 11:48:08 [error] 1712#2324: *2 CreateFile() "C:\nginx/html/50x.html" failed (2: The system cannot find the file specified), client: 158.69.21.193, server: localhost, request: "GET /assets/hk/ajax/active_content.php?_=1443465991126 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "158.69.21.193", referrer: "http://158.69.21.193/hk/index.php?url=index"

2

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]