Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smokeping helper FCGI - OSError: [Errno 88] Socket operation on non-socket #12

Open
AlexDicy opened this issue Jun 6, 2023 · 0 comments

Comments

@AlexDicy
Copy link

AlexDicy commented Jun 6, 2023

Hello! I've been having issues setting up the fcgi script, I'm using the same setup that I'm using for smokeping itself, but I'm not able to get past this error. NGINX ends up reporting a 502 Bad Gateway whenever I try to call /smokeping/smokeping_th_helper.fcgi

I have followed the steps in the readme which includes:

  • Initialized the database (successful)
  • Ran a couple of updates using the traceroute_history_runner.py --update-now command (successful after forcing tzlocal<3.0)
  • Tried running and opening the Web GUI (works fine after changing the install_dir path)
  • Created the symbolic link for smokeping_th_helper.fcgi
  • Copied the nginx config and restarted nginx service
  • Tested both smokeping (working as usual) and the smokeping_th_helper.fcgi (502 Bad Gateway)

NGINX config:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                fastcgi_intercept_errors on;

                fastcgi_param   SCRIPT_FILENAME         /usr/lib/cgi-bin/smokeping.cgi;
                fastcgi_param   QUERY_STRING            $query_string;
                fastcgi_param   REQUEST_METHOD          $request_method;
                fastcgi_param   CONTENT_TYPE            $content_type;
                fastcgi_param   CONTENT_LENGTH          $content_length;
                fastcgi_param   REQUEST_URI             $request_uri;
                fastcgi_param   DOCUMENT_URI            $document_uri;
                fastcgi_param   DOCUMENT_ROOT           $document_root;
                fastcgi_param   SERVER_PROTOCOL         $server_protocol;
                fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
                fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;
                fastcgi_param   REMOTE_ADDR             $remote_addr;
                fastcgi_param   REMOTE_PORT             $remote_port;
                fastcgi_param   SERVER_ADDR             $server_addr;
                fastcgi_param   SERVER_PORT             $server_port;
                fastcgi_param   SERVER_NAME             $server_name;
                fastcgi_param   HTTPS                   $https if_not_empty;

                fastcgi_pass unix:/var/run/fcgiwrap.socket;
                #fastcgi_read_timeout 300;
        }


        location ^~ /smokeping/ {
                alias /usr/share/smokeping/www/;
                index smokeping.cgi;
                gzip off;
        }

        location = /smokeping/smokeping_th_helper.fcgi {
                alias /opt/traceroute_history/smokeping_th_helper.fcgi;

                fastcgi_intercept_errors on;

                fastcgi_param   SCRIPT_FILENAME         /usr/lib/cgi-bin/smokeping_th_helper.fcgi;
                fastcgi_param   QUERY_STRING            $query_string;
                fastcgi_param   REQUEST_METHOD          $request_method;
                fastcgi_param   CONTENT_TYPE            $content_type;
                fastcgi_param   CONTENT_LENGTH          $content_length;
                fastcgi_param   REQUEST_URI             $request_uri;
                fastcgi_param   DOCUMENT_URI            $document_uri;
                fastcgi_param   DOCUMENT_ROOT           $document_root;
                fastcgi_param   SERVER_PROTOCOL         $server_protocol;
                fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
                fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;
                fastcgi_param   REMOTE_ADDR             $remote_addr;
                fastcgi_param   REMOTE_PORT             $remote_port;
                fastcgi_param   SERVER_ADDR             $server_addr;
                fastcgi_param   SERVER_PORT             $server_port;
                fastcgi_param   SERVER_NAME             $server_name;
                fastcgi_param   HTTPS                   $https if_not_empty;

                fastcgi_pass unix:/var/run/fcgiwrap.socket;
        }
}

Running the script manually:

alex@dicypi:/opt/traceroute_history $ sudo ./smokeping_th_helper.fcgi
Traceback (most recent call last):
  File "/opt/traceroute_history/./smokeping_th_helper.fcgi", line 76, in <module>
    WSGIServer(app).run()
  File "/home/alex/.local/lib/python3.9/site-packages/flup/server/fcgi.py", line 111, in run
    sock = self._setupSocket()
  File "/home/alex/.local/lib/python3.9/site-packages/flup/server/fcgi_base.py", line 1025, in _setupSocket
    sock = socket.fromfd(FCGI_LISTENSOCK_FILENO, socket.AF_INET,
  File "/usr/lib/python3.9/socket.py", line 545, in fromfd
    return socket(family, type, proto, nfd)
  File "/usr/lib/python3.9/socket.py", line 232, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 88] Socket operation on non-socket

Running it through nginx (opening http://dicypi/smokeping/smokeping_th_helper.fcgi):

2023/06/06 21:08:01 [error] 646357#646357: *82 FastCGI sent in stderr: "Traceback (most recent call last):
  File "/usr/lib/cgi-bin/smokeping_th_helper.fcgi", line 76, in <module>
    WSGIServer(app).run()
  File "/usr/local/lib/python3.9/dist-packages/flup/server/fcgi.py", line 111, in run
    sock = self._setupSocket()
  File "/usr/local/lib/python3.9/dist-packages/flup/server/fcgi_base.py", line 1025, in _setupSocket
    sock = socket.fromfd(FCGI_LISTENSOCK_FILENO, socket.AF_INET,
  File "/usr/lib/python3.9/socket.py", line 545, in fromfd
    return socket(family, type, proto, nfd)
  File "/usr/lib/python3.9/socket.py", line 232, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 88] Socket operation on non-socket" while reading response header from upstream, client: 192.168.1.77, server: _, request: "GET /smokeping/smokeping_th_helper.fcgi HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "192.168.1.22"
2023/06/06 21:08:01 [error] 646357#646357: *82 upstream prematurely closed FastCGI stdout while reading response header from upstream, client: 192.168.1.77, server: _, request: "GET /smokeping/smokeping_th_helper.fcgi HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "192.168.1.22"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant