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

Webhooks causing FileNotFoundError #1976

Open
BenCurtisD opened this issue Jul 21, 2023 · 3 comments
Open

Webhooks causing FileNotFoundError #1976

BenCurtisD opened this issue Jul 21, 2023 · 3 comments
Labels
Platform: Windows Pertaining only to Windows (tier 2) Status: not gevent Environment or otherwise not a gevent issue. No further work expected. Type: Question User support and/or waiting for responses

Comments

@BenCurtisD
Copy link

BenCurtisD commented Jul 21, 2023

  • gevent version: Pip installed, Version: 23.7.0
  • Python version: Python 3.11.0 downloaded from python.org
  • Operating System: Microsoft Windows Version 22H2 (OS Build 22521.1992)

Description:

I am trying to use webhooks from clickup to trigger python scripts using flask through gevent. The webhooks are clearly being received by the server, however instead of the desired functionality, I just get a gevent related error.

Traceback (most recent call last):
  File "src\\gevent\\greenlet.py", line 908, in gevent._gevent_cgreenlet.Greenlet.run
  File "C:\Users\Ben\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\baseserver.py", line 34, in _handle_and_close_when_done
    return handle(*args_tuple)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ben\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\server.py", line 209, in wrap_socket_and_handle
    with _closing_socket(self.wrap_socket(client_socket, **self.ssl_args)) as ssl_socket:
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ben\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\ssl.py", line 785, in wrap_socket
    return SSLSocket(sock=sock, keyfile=keyfile, certfile=certfile,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ben\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\ssl.py", line 319, in __init__
    raise x
  File "C:\Users\Ben\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\ssl.py", line 315, in __init__
    self.do_handshake()
  File "C:\Users\Ben\AppData\Local\Programs\Python\Python311\Lib\site-packages\gevent\ssl.py", line 673, in do_handshake
    self._sslobj.do_handshake()
FileNotFoundError: [Errno 2] No such file or directory
2023-07-21T02:23:26Z <Greenlet at 0x16bd56647c0: _handle_and_close_when_done(<bound method StreamServer.wrap_socket_and_handle , <bound method StreamServer.do_close of <WSGIServer, (<gevent._socket3.socket [closed] at 0x16bdfb219c0)> failed with FileNotFoundError

What I've run:

@app.route('/triggerauth')
def triggerAuth(methods=['POST']):
    return str(request.form)
from gevent import monkey
monkey.patch_all()

import sys
import gevent
from gevent.pywsgi import WSGIServer
from app import app, appInfo

new_env = {'GATEWAY_INTERFACE': 'CGI/1.1',
                'SERVER_SOFTWARE': 'gevent/%d.%d Python/%d.%d' % (gevent.version_info[:2] + sys.version_info[:2]),
                'SCRIPT_NAME': '',
                'wsgi.version': (1, 0),
                'wsgi.multithread': True, 
                'wsgi.multiprocess': True,
                'wsgi.run_once': False}

if appInfo["debug"]:
    http_server = WSGIServer(("0.0.0.0", appInfo["port"]), app, ssl_args='adhoc', environ=new_env)
    http_server.serve_forever()
else:
    http_server = WSGIServer(("0.0.0.0", appInfo["port"]), app, keyfile=appInfo["cert"] + '/privkey.pem', certfile=appInfo["cert"] + '/cert.pem', environ=new_env) 
    http_server.serve_forever()

Sorry in advance if I've made any errors with this issue report, I've never made one before.

@BenCurtisD
Copy link
Author

I realize my actual code for detecting the webhook as it stands wouldn't help me know what I received but I will obviously change that as soon as I'm not having immediate gevent related errors.

@jamadden
Copy link
Member

The message pretty clearly seems to indicate that you're providing an SSL key or certificate (keyfile, certfile) that doesn't exist. Have you confirmed that the paths you're creating do in fact exist? (Also, be sure to use os.path.join() instead of string concatenation to form your path strings; you're on Windows --- which is only supported for development not production --- but using a POSIX separator; since the error is coming from the guts of OpenSSL, they may be expecting correctly-formed paths.)

@jamadden jamadden added Status: not gevent Environment or otherwise not a gevent issue. No further work expected. Type: Question User support and/or waiting for responses Platform: Windows Pertaining only to Windows (tier 2) labels Jul 21, 2023
@BenCurtisD
Copy link
Author

I have made the changes for the path formatting, and it still has the same results. I know that the files are there because the server is already successfully working for browser use from outside connections. Only trying to use webhooks to this URL is causing errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Windows Pertaining only to Windows (tier 2) Status: not gevent Environment or otherwise not a gevent issue. No further work expected. Type: Question User support and/or waiting for responses
Projects
None yet
Development

No branches or pull requests

2 participants