Join the community today
Register Now

Nginx Nginx Socket Leaks

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by negative, Dec 10, 2015.

Tags:
  1. negative

    negative Member

    216
    22
    18
    Apr 11, 2015
    Ratings:
    +50
    Local Time:
    2:01 AM
    1.9.10
    10.1.11
    Hello everyone

    I see these errors on nginx error log. Are they important and how can i fix this problem ?

    Code:
    [root@server ~]# tail -10 /usr/local/nginx/logs/error.log
    Code:
    2015/12/10 01:36:39 [alert] 27263#27263: *241 open socket #71 left in connection 5
    2015/12/10 01:36:39 [alert] 27263#27263: *242 open socket #73 left in connection 6
    2015/12/10 01:36:39 [alert] 27263#27263: aborting
    2015/12/10 02:15:33 [alert] 27898#27898: *5336 open socket #52 left in connection 7
    2015/12/10 02:15:33 [alert] 27898#27898: *5335 open socket #46 left in connection 9
    2015/12/10 02:15:33 [alert] 27898#27898: aborting
    2015/12/10 02:44:04 [alert] 28030#28030: *18754 open socket #73 left in connection 3
    2015/12/10 02:44:04 [alert] 28030#28030: *18753 open socket #71 left in connection 7
    2015/12/10 02:44:04 [alert] 28030#28030: aborting
    
    Thank you.
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,563
    6,851
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,268
    Local Time:
    10:01 AM
    Nginx 1.13.x
    MariaDB 5.5
    yes socket leaks.. you using default centmin mod out of box settings in nginx.conf and nginx vhost ? post your nginx.conf settings

    If you have a lot of free disk space, you can enable debug nginx version and compile a nginx debug build of nginx via centmin.sh option NGINX_DEBUG=y centminmod/centmin.sh at 123.08stable · centminmod/centminmod · GitHub

    You can place the option in persistent config /etc/centminmod/custom_config.inc outlined at centminmod.com/upgrade.html#persistent so place in file /etc/centminmod/custom_config.inc
    Code:
    NGINX_DEBUG=y
    then recompile nginx via centmin.sh menu option 4 and then in your nginx error_log directive add debug option A debugging log and restart nginx and check logs

    They will be very very very verbose and lot alot to disk usage logged to error logs, so ensure you have a lot of disk free space.

    You can minimise this by limiting it to specific ip based client connections too
    After debugging is done, reverse the debug now by setting NGINX_DEBUG=n and recompile Nginx again.

    Then you can look at debugging at Debugging | NGINX
     
  3. eva2000

    eva2000 Administrator Staff Member

    30,563
    6,851
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,268
    Local Time:
    10:01 AM
    Nginx 1.13.x
    MariaDB 5.5
    Centmin Mod is provided as is so debugging is left to end user. If you are using non-default nginx.conf settings, I suggest you revert to default and try first

    Also if you haven't already, update to Nginx 1.9.9 which has bug fix for 1.9.8 but update to latest Centmin Mod 123.08stable or 123.09beta01 first
     
    Last edited: Dec 10, 2015
  4. negative

    negative Member

    216
    22
    18
    Apr 11, 2015
    Ratings:
    +50
    Local Time:
    2:01 AM
    1.9.10
    10.1.11
    Hello @eva2000

    I' m using that nginx.conf

    I have changed following values instead of your original conf

    map_hash_bucket_size 128; #for 500 custom url rewrites map
    worker_processes 24; #cpu count total is 24 on my dedicated server
    worker_connections 16384; #for better performance on server

    Code:
    user              nginx nginx;
    worker_processes 24;
    worker_priority -10;
    
    worker_rlimit_nofile 260000;
    timer_resolution 100ms;
    
    pcre_jit on;
    
    pid         logs/nginx.pid;
    
    events {
        worker_connections  16384;
        accept_mutex on;
        accept_mutex_delay 200ms;
        use epoll;
        multi_accept on;
    }
    
    http {
    #limit_req_zone $binary_remote_addr zone=xwplogin:16m rate=40r/m;
    #limit_conn_zone $binary_remote_addr zone=xwpconlimit:16m;
    
    more_set_headers "Server: nginx centminmod";
    
    map_hash_bucket_size 128;
    
    include /usr/local/nginx/conf/vts_http.conf;
    include /usr/local/nginx/conf/geoip.conf;
    include /usr/local/nginx/conf/pagespeedadmin.conf;
    include /usr/local/nginx/conf/fastcgi_param_https_map.conf;
    
    log_format      main    '$remote_addr - $remote_user [$time_local] $request '
                    '"$status" $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"'
                    ' "$connection" "$connection_requests" "$request_time"';
    
    access_log  logs/access.log combined buffer=128k flush=5m;
    error_log   logs/error.log warn;
    
        index  index.php index.html index.htm;
        include       mime.types;
        default_type  application/octet-stream;
        charset utf-8;
    
            sendfile on;
            sendfile_max_chunk 512k;
            tcp_nopush  on;
            tcp_nodelay on;
            server_tokens off;
            server_name_in_redirect off;
        
            keepalive_timeout  8;
            keepalive_requests 1000;
            lingering_time 20s;
            lingering_timeout 5s;
            keepalive_disable msie6;
    
        gzip on;
        gzip_vary   on;
        gzip_disable "MSIE [1-6]\.";
            gzip_static on;
            gzip_min_length   1400;
            gzip_buffers      32 8k;
            gzip_http_version 1.0;
            gzip_comp_level 5;
            gzip_proxied    any;
            gzip_types text/plain text/css text/xml application/javascript application/x-javascript application/xml application/xml+rss application/ecmascript application/json image/svg+xml;
    
    client_body_buffer_size 256k;
    client_body_in_file_only off;
    client_body_timeout 10s;
    client_header_buffer_size 64k;
    ## how long a connection has to complete sending
    ## it's headers for request to be processed
    client_header_timeout  8s;
    client_max_body_size 50m;
    connection_pool_size  512;
    directio  4m;
    ignore_invalid_headers on;   
    large_client_header_buffers 8 64k;
    output_buffers   8 256k;
    postpone_output  1460;
    proxy_temp_path  /tmp/nginx_proxy/;
    request_pool_size  32k;
    reset_timedout_connection on;
    send_timeout     15s;
    types_hash_max_size 2048;
    server_names_hash_bucket_size 64;
    
    # for nginx proxy backends to prevent redirects to backend port
    # port_in_redirect off;
    
    open_file_cache max=50000 inactive=60s;
    open_file_cache_valid 120s;
    open_file_cache_min_uses 2;
    open_file_cache_errors off;
    open_log_file_cache max=10000 inactive=30s min_uses=2;
    
    ## limit number of concurrency connections per ip to 16
    ## add to your server {} section the next line
    ## limit_conn limit_per_ip 16;
    ## uncomment below line allows 500K sessions
    # limit_conn_log_level error;
    #######################################
    # use limit_zone for Nginx <v1.1.7 and lower
    # limit_zone $binary_remote_addr zone=limit_per_ip:16m;
    #######################################
    # use limit_conn_zone for Nginx >v1.1.8 and higher
    # limit_conn_zone $binary_remote_addr zone=limit_per_ip:16m;
    #######################################
    
    include /usr/local/nginx/conf/conf.d/*.conf;
    }