Manga-Colorizer icon indicating copy to clipboard operation
Manga-Colorizer copied to clipboard

Ngrok error

Open rsaurav12 opened this issue 1 year ago • 1 comments

I'm trying to run this in colab. !pip install pyngrok from pyngrok import ngrok ngrok.set_auth_token("auth_token") public_url = ngrok.connect(5000).public_url print(public_url)

Then Start the python app-stream.py

Got this error: ERR_NGROK_3004 ngrok gateway error

The server returned an invalid or incomplete HTTP response.

Get help with this error

rsaurav12 avatar Dec 18 '24 17:12 rsaurav12

Just use it like:

!pip install pyngrok
!ngrok config add-authtoken {NGROK_AUTHTOKEN}
!ngrok http 5000

Or if you want to run in a separate thread with static domain:

import subprocess

ngrok_process = None

def run_ngrok():
    global ngrok_process
    command = ["ngrok", "http", f"--domain={NGROK_STATIC_DOMAIN}", "5003"]
    ngrok_process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
    for line in ngrok_process.stdout:
        print(line.strip())
    
def stop_ngrok():
    global ngrok_process
    if ngrok_process:
        ngrok_process.terminate()

For start:

ngrok_thread = threading.Thread(target=run_ngrok, daemon=True)
ngrok_thread.start()

For stop:

stop_ngrok()
ngrok_thread.join()

BinitDOX avatar Dec 18 '24 19:12 BinitDOX