0

I have a custom config here is the sample:

log_level: info
region: ap
tunnels:
  http:
    addr: 5000
    proto: http
  ssh:
    addr: 22
    proto: tcp

I specify the config path on pyngrok but when I try to run ngrok.connect() only HTTP part is working and show on my ngrok dashboard, no ssh tunnel. When I try the ngrok binary provided by pyngrok:

ngrok start --all --config=/ngrok.yaml 

It works! On my ngrok dashboard I have HTTP, HTTPS and TCP.

Falcon Ryu
  • 475
  • 1
  • 6
  • 17

2 Answers2

0

These commands do not map to each other, which is why they do not do the same thing. connect() calls ngrok start --none, so it starts the ngrok process and API with no tunnels running, then it starts a tunnel using the API with the params you've passed to connect(). To start multiple tunnels, just call connect() more than once with different params.

from pyngrok import ngrok

conf.get_default().region = "ap"

tunnel1 = ngrok.connect(addr=5000)
tunnel2 = ngrok.connect(addr=22, proto="tcp")

In the above example, the config file isn't even necessary. If you already have tunnel definitions in your config though, you can use them by just passing their name.

from pyngrok import ngrok

conf.get_default().config_path = "/ngrok.yml"


tunnel1 = ngrok.connect(name="http")
tunnel1 = ngrok.connect(name="tcp")

The docs, which have many examples of this and other usage, can be found here.

alexdlaird
  • 1,174
  • 12
  • 34
0

maybe is not the solution but this worked for me

tunnels:
  http:
    addr: 5000
    proto: http
  ssh:
    addr: 22
    proto: tcp

ngrok start http ssh

Rolly
  • 3,205
  • 3
  • 26
  • 35