2

I have just set up nginx on my website and when ever visitors are visiting the php-cgi.exe and the website is becoming very slow, and I am unsure if it is loading at all. nginx.exe is still running as a service from what I can see. Below is my error log (same sort of messages every time), I think they are to do with ajax calls, I am very confused on why it is doing this, and how I can fix it.

Errors:

    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"

After php-cgi.exe closes, I start receiving these errors

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"

Stopping and starting nginx fixes it for another 5 minutes untill about 15 ajax calls are made untill it crashes again!!? An ajax call is called ever 1 second to update a chatbox

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 call page:

<?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 config:

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;
    #    }
    #}

}

The ajax calls keep going even when php-cgi close though, but you can't reload as the website will display as offline.

edit4 log update:

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"
Josh Hallow
  • 359
  • 3
  • 15
  • post your nginx conf, also how many rows you have in `craft_hk_messages` table in your database? – mergenchik Sep 28 '15 at 09:30
  • About 500 max, and I have updated my question. – Josh Hallow Sep 28 '15 at 16:02
  • can you do the following: (1) close server for remote access, so only you can access it, (2) stop nginx, clear all logs, (3) start nginx and try to access all the pages one by one, especially to `recent_logins.php`, `active_content.php`. (4) update log in the question. I suspect that something in the pages I have listed crashes your `php-cgi.exe`, so subsequent requests fail. – mergenchik Sep 28 '15 at 18:01
  • @mergenchik http://prntscr.com/8liumc is the error I get in the google chrome console, and the php-cgi still crashes, visiting the recent_logins.php and active_content.php works fine, its just the page that they are called by ajax that is the problem. Question updated with the new log (under edit4) – Josh Hallow Sep 28 '15 at 18:50

0 Answers0