Skip to content

Ngrok error #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rsaurav12 opened this issue Dec 18, 2024 · 1 comment
Open

Ngrok error #21

rsaurav12 opened this issue Dec 18, 2024 · 1 comment

Comments

@rsaurav12
Copy link

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

@BinitDOX
Copy link
Owner

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants