为什么 Pyngrok 检测不到我的配置文件?

Why doesn't pyngrok detect my config file?

我正在尝试使用我自己的配置文件 pyngrok 但我不明白为什么它没有检测到它,我的项目需要 运行 强制 sudo ,因此 ngrok 没有检测到某些用户的 root 主目录中的配置文件,这就是为什么我想在我的项目目录中挂载我自己的配置文件,这是我的代码:

from pyngrok import ngrok, conf
import os
from pathlib import Path
import re

def ngrok_start ():
        file = Path (".config/ngrok.yml")
        if file.exists():
                os.system("kill -9 $(pgrep ngrok)")
                ngrok.DEFAULT_CONFIG_PATH = ".config/ngrok.yml"
                ngrok.connect(443, "tcp")
                while True:
                        ngrok_tunnels = ngrok.get_tunnels()
                        url = ngrok_tunnels[0].public_url
                        if re.match ("tcp://[0-9]*.tcp.ngrok.io:[0-9]*", url) is not None:
                                print ("Ngrok TCP:" + url)
                                break

我的代码出现以下错误:

Traceback (most recent call last):
  File "ngrok.py", line 27, in <module>
    ngrok_start ()
  File "ngrok.py", line 20, in ngrok_start
    ngrok.connect (443, "tcp")
  File "/usr/local/lib/python2.7/dist-packages/pyngrok/ngrok.py", line 181, in connect
    timeout = pyngrok_config.request_timeout))
  File "/usr/local/lib/python2.7/dist-packages/pyngrok/ngrok.py", line 321, in api_request
    status_code, e.msg, e.hdrs, response_data)
pyngrok.exception.PyngrokNgrokHTTPError: ngrok client exception, API returned 502: {"error_code": 103, "status_code": 502, "msg": "failed to start tunnel", "details": {"err": "TCP tunnels are only available after you sign up. \ nSign up at: https://ngrok.com/signup\n\nIf you have already signed up, make sure your authtoken is installed. \ nYour authtoken is available on your dashboard: https: //dashboard.ngrok.com/auth/your-authtoken\r\n\r\nERR_NGROK_302\r\n "}}
No handlers could be found for logger "pyngrok.process"

我的脚本在lib文件夹,我的配置文件在.config/ngrok.yml里面,里面有我的token,但是我检测不到,希望大家多多支持,谢谢

imagen

Per the docsDEFAULT_CONFIG_PATH变量在conf模块中,而不是ngrok模块中。所以将 ngrok.DEFAULT_CONFIG_PATH = 更改为 conf.get_default().config_path = .