alexdlaird / pyngrok

A Python wrapper for ngrok
https://pyngrok.readthedocs.io
MIT License
425 stars 59 forks source link

pyngrok.exception.PyngrokNgrokError: The ngrok process was unable to start #15

Closed donmbelembe closed 5 years ago

donmbelembe commented 5 years ago

OS: windows 10 I have my own ngrok server, from the command I use ngrok.exe -config=config.txt -proto=tcp 5900 but when I'm trying to reproduce the same with python i'm getting this error

this is my code

from pyngrok import ngrok
CONFIG_PATH = "./config.yml"
ngrok.DEFAULT_NGROK_PATH = "./ngrok.exe"
public_url = ngrok.connect(port=5900, proto='tcp', config_path=CONFIG_PATH)
ngrok_process = ngrok.get_ngrok_process()
ngrok_process.process.wait()

the error

Traceback (most recent call last):
  File "tunnel.py", line 5, in <module>
    public_url = ngrok.connect(port=5900, proto='tcp', config_path=CONFIG_PATH)
  File "C:\Users\donmb\Documents\Projects\don\tunel\venv\lib\site-packages\pyngrok\ngrok.py", line 158, in connect
    api_url = get_ngrok_process(ngrok_path, config_path).api_url
  File "C:\Users\donmb\Documents\Projects\don\tunel\venv\lib\site-packages\pyngrok\ngrok.py", line 117, in get_ngrok_process
    return process.get_process(ngrok_path, config_path)
  File "C:\Users\donmb\Documents\Projects\don\tunel\venv\lib\site-packages\pyngrok\process.py", line 78, in get_process
    _start_process(ngrok_path, config_path)
  File "C:\Users\donmb\Documents\Projects\don\tunel\venv\lib\site-packages\pyngrok\process.py", line 187, in _start_process
    raise PyngrokNgrokError("The ngrok process was unable to start")
pyngrok.exception.PyngrokNgrokError: The ngrok process was unable to start
alexdlaird commented 5 years ago

Thank you for the helpful description and stack trace. I will look in to this later this week if not today.

alexdlaird commented 5 years ago

Unclear what the issue with your code is, but it's likely related to the fact that you're overriding CONFIG_PATH and DEFAULT_NGROK_PATH with values that don't exist (or the path is wrong) or are corrupt—no issue with pyngrok or ngrok.

Testing on Mac and Windows, using ngrok tcp -config=~/.ngrok2/ngrok.yml 5900 properly starts a TCP tunnel (assuming an auth token is set, otherwise it will error since an account is required for this action). This command uses the ngrok binary installed via pyngrok.

Similarly, using the following code also works without error:

from pyngrok import ngrok

public_url = ngrok.connect(port=5900, proto='tcp', config_path='~/.ngrok2/ngrok.yml')
ngrok_process = ngrok.get_ngrok_process()
ngrok_process.process.wait()
donmbelembe commented 5 years ago

Actually I have my own compiled ngrok executable, I use that to connect to my own ngrok server