Najmi
Najmi

Reputation: 11

Pyngrok & Flask, Your account is limited to 1 simultaneous ngrok agent session

I trying to run both flask and ngrok in the same script for a program for my user so they dont need to setup ngrok manually.I tried pyngrok but i got an error.

Script:

from flask import Flask, request

#ngrok
ngrok.set_auth_token("Auth Key Here")
ngrok_ = ngrok.connect()

#flask
app = Flask(__name__)

@app.route("/test", methods=['GET', 'POST'])
def test():
    return "Nothing"

app.run(debug=True, port=80)

Output:

 * Serving Flask app 'Pyngrok' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Restarting with stat
t=2022-06-04T18:02:07+0800 lvl=warn msg="can't bind default web address, trying alternatives" obj=web addr=127.0.0.1:4040
t=2022-06-04T18:02:08+0800 lvl=eror msg="failed to auth" obj=tunnels.session err="Your account is limited to 1 simultaneous ngrok agent session.\nActive ngrok agent sessions in region 'us':\n  - ts_2A6jSBg4Jw4kn6rjgD7ZCIxtNe7 (2001:e68:5472:fe1c:f419:f131:ac2d:198)\r\n\r\nERR_NGROK_108\r\n"
t=2022-06-04T18:02:08+0800 lvl=eror msg="failed to reconnect session" obj=csess id=a934dc9aabeb err="Your account is limited to 1 simultaneous ngrok agent session.\nActive ngrok agent sessions in region 'us':\n  - ts_2A6jSBg4Jw4kn6rjgD7ZCIxtNe7 (2001:e68:5472:fe1c:f419:f131:ac2d:198)\r\n\r\nERR_NGROK_108\r\n"
t=2022-06-04T18:02:08+0800 lvl=eror msg="session closing" obj=tunnels.session err="Your account is limited to 1 simultaneous ngrok agent session.\nActive ngrok agent sessions in region 'us':\n  - ts_2A6jSBg4Jw4kn6rjgD7ZCIxtNe7 (2001:e68:5472:fe1c:f419:f131:ac2d:198)\r\n\r\nERR_NGROK_108\r\n"
t=2022-06-04T18:02:08+0800 lvl=eror msg="terminating with error" obj=app err="Your account is limited to 1 simultaneous ngrok agent session.\nActive ngrok agent sessions in region 'us':\n  - ts_2A6jSBg4Jw4kn6rjgD7ZCIxtNe7 (2001:e68:5472:fe1c:f419:f131:ac2d:198)\r\n\r\nERR_NGROK_108\r\n"
t=2022-06-04T18:02:08+0800 lvl=crit msg="command failed" err="Your account is limited to 1 simultaneous ngrok agent session.\nActive ngrok agent sessions in region 'us':\n  - ts_2A6jSBg4Jw4kn6rjgD7ZCIxtNe7 (2001:e68:5472:fe1c:f419:f131:ac2d:198)\r\n\r\nERR_NGROK_108\r\n"
Traceback (most recent call last):
  File "C:\Users\najmi\PycharmProjects\exe otp bot\Test Script\Pyngrok.py", line 6, in <module>
    print(ngrok.get_ngrok_process())
  File "C:\Users\najmi\AppData\Local\Programs\Python\Python310\lib\site-packages\pyngrok\ngrok.py", line 162, in get_ngrok_process
    return process.get_process(pyngrok_config)
  File "C:\Users\najmi\AppData\Local\Programs\Python\Python310\lib\site-packages\pyngrok\process.py", line 295, in get_process
    return _start_process(pyngrok_config)
  File "C:\Users\najmi\AppData\Local\Programs\Python\Python310\lib\site-packages\pyngrok\process.py", line 464, in _start_process
    raise PyngrokNgrokError("The ngrok process errored on start: {}.".format(ngrok_process.startup_error),
pyngrok.exception.PyngrokNgrokError: The ngrok process errored on start: Your account is limited to 1 simultaneous ngrok agent session.\nActive ngrok agent sessions in region 'us':\n  - ts_2A6jSBg4Jw4kn6rjgD7ZCIxtNe7 (2001:e68:5472:fe1c:f419:f131:ac2d:198)\r\n\r\nERR_NGROK_108\r\n.


I dont think its my account because i resetted auth token for this script

Do you guys encountered this issue before? If yes, how do you guys fix this?

Upvotes: 1

Views: 4242

Answers (1)

Najmi
Najmi

Reputation: 11

I found the problem ig. You cant use debug from flask.its probably because flask rerun the script thus make the ngrok to establish new connection but for free acc you can only only have 1 conccurent connection ig. hope this helpful

Upvotes: 0

Related Questions