1

I am trying to run ngrok with options I tried

from pyngrok import ngrok
ngrokPublicUrl = ngrok.connect(5000, bind_tls= True)

and

ngrokPublicUrl = ngrok.connect(remote_addr=5000, bind_tls= True)

For options I used the documentation here --> https://ngrok.com/docs#tunnel-definitions. I am trying to get the https address not http. It looks like options usage is not correct?

but I get this error

TypeError: connect() got an unexpected keyword argument 'remote_addr'

or

TypeError: connect() got an unexpected keyword argument 'bind_tls'
alexdlaird
  • 1,174
  • 12
  • 34
Ghost
  • 549
  • 8
  • 29
  • 1
    From the pyngrok documentation: "The connect() method can also take an options parameter, which allows us to pass additional options that are supported by ngrok." So something like `ngrok.connect(options={'remote_addr': 5000, 'bind_tls': True})` I think – jasonharper Oct 02 '19 at 16:22
  • Thx I am looking for python usage tried already --> ngrok.connect('remote_addr':5000) or ngrok.connect('remote_addr'=5000) the trouble is usage how do I use it with python or the syntax – Ghost Oct 02 '19 at 17:23

1 Answers1

0

Update

With pyngrok>=5, options have been unpacked to kwargs, meaning the question asker's original syntax will now work just fine, though it should also be noted with this update that connect() now returns a NgrokTunnel instead of the public_url as a str like it used to.

Original Answer (for pyngrok<=4.1)

I am the developer of pyngrok. The correct Python snippet was given in the comment above, I'll post it here as well so it can be marked as an answered.

You cannot pass this parameter directly to the connect(), as you are trying to do, you need to pass it as an options dictionary to connect() (which will be unpacked to the tunnel definitions in the documentation you've linked—see the API docs here).

from pyngrok import ngrok

options = {
   "remote_addr": 5000,
   "bind_tls": True
}
ngrokPublicUrl = ngrok.connect(options=options)

Perhaps options would more intuitively be unpacked in connect() as kwargs? I'll take note of that to consider as a future improvement, but for now you need to do it the way described above.

alexdlaird
  • 1,174
  • 12
  • 34