alexdlaird / pyngrok

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

reset_session function #72

Closed DoubleF3lix closed 3 years ago

DoubleF3lix commented 3 years ago

I'm making a program that utilizes this library and can open and close tunnels with a function, but if too many sessions are opened and closed, I get an error that says that I can only open 4 per session. A function to reset the session so I can open new tunnels again would be useful so the user doesn't have to re-open the UI.

Something like ngrok.reset_session() that would raise an error if there are any tunnels open.

alexdlaird commented 3 years ago

I believe this limitation of 4 is applied only to ngrok free accounts, so that's one way to get more simultaneous open tunnels.

Why not just ngrok.disconnect() the unused tunnels when a new tunnel is needed? If you want to disconnect all tunnels and start fresh, use ngrok.kill() and then create a new object. The interfaces to accomplish this behavior are already there, so I don't think it's something that we need to add to the pyngrok APIs.