-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into mandy/device-gateway-sdk
- Loading branch information
Showing
15 changed files
with
261 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,16 @@ This error occurs when there is no active tunnel using the hostname you are tryi | |
|
||
If you are the ngrok Administrator for this account, please verify that the ngrok Agent is running and that the subdomain/hostname is correct. | ||
|
||
If you are not the ngrok Administrator and are a visitor to the ngrok URL, you may need to contact the endpoint owner through other means. | ||
ngrok is unable to assist with end user content as all content is neither hosted or maintained by ngrok. ngrok is unable to provide user details per the ngrok privacy policy. | ||
|
||
### The most common causes of this error are: | ||
|
||
- The ngrok Agent is no longer running, or you forgot to start the Agent. Verify that the Agent is running and showing the expected "Forwarding" address. | ||
- The Agent session has timed out or stopped. Restart the ngrok Agent to restart the Agent and tunnel sessions. | ||
- The endpoint domain/hostname has changed. If you are on the Free plan or have not set the `--domain` flag to set the domain on the tunnel, please be aware that the forwarding address will change each time the Agent and session are restarted. If you previously obtained a forwarding URL from an agent session but have since closed that session or closed the client window, the URL will change when a new Agent session starts. | ||
- You have made a typo in the endpoint address you have entered in the browser. Verify that the tunnel hostname is correct. Incorrectly entering the address (a typo) in a browser address bar can also result in this error. | ||
- A network issue exists between the device the Agent is running on and ngrok. Your ngrok agent might have trouble reaching the ngrok service. Try running the [`ngrok diagnose`](/docs/agent/cli/#ngrok-diagnose) command to check for connectivity issues. | ||
- You are attempting to run `--scheme http` on your agent using a domain that only supports https. All of the `.app` and `.dev` domains are HSTS or "HTTP Strict Transport Security" domains. Paid plan accounts are able to start http scheme tunnels on the `ngrok.io` domain, which is not HSTS enforced. | ||
- **Agent Not Running** The ngrok Agent is no longer running, or you forgot to start the Agent. Verify that the Agent is running and showing the expected "Forwarding" address. | ||
- **Session Timed Out or Stopped** The Agent session has timed out or stopped. Restart the ngrok Agent to restart the Agent and tunnel sessions. | ||
- **Endpoint Domain or Hostname Change** The endpoint domain or hostname has changed. If you are on the Free plan or have not set the `--domain` flag to set the domain on the tunnel, please be aware that the forwarding address will change each time the Agent and session are restarted. If you previously obtained a forwarding URL from an agent session but have since closed that session or closed the client window, the URL will change when a new Agent session starts. | ||
- **Typo in Endpoint Address** You have made a typo in the endpoint address you have entered in the browser. Verify that the tunnel hostname is correct. Incorrectly entering the address (a typo) in a browser address bar can also result in this error. | ||
- **Network Issues** A network issue exists between the device the Agent is running on and ngrok. Your ngrok agent might have trouble reaching the ngrok service. Try running the [`ngrok diagnose`](/docs/agent/cli/#ngrok-diagnose) command to check for connectivity issues. | ||
- **Incorrect Scheme** You are attempting to run `--scheme http` on your agent using a domain that only supports https. All of the `.app` and `.dev` domains are HSTS or "HTTP Strict Transport Security" domains. Paid plan accounts are able to start http scheme tunnels on the `ngrok.io` domain, which is not HSTS enforced. | ||
|
||
If you are the Administrator for this account, and none of these steps work for you or you have additional questions, drop us a note at at [[email protected]](mailto:[email protected]?subject=Help%20with%20ngrok%203200%20error). | ||
If you are the Administrator for this ngrok account, and none of these steps work for you or you have additional questions, drop us a note at at [[email protected]](mailto:[email protected]?subject=Help%20with%20ngrok%203200%20error). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
### Additional Information | ||
|
||
## Are you the developer? | ||
|
||
We display this page to prevent abuse. Visitors to your site will only see it once. | ||
If you are attempting to access an endpoint programmatically and are still encountering this error, the interstitial page can be bypassed. | ||
|
||
## To remove this page: | ||
|
||
- Set and send an ngrok-skip-browser-warning request header with any value. | ||
- Or, set and send a custom/non-standard browser User-Agent request header. | ||
- Or, please [upgrade](https://dashboard.ngrok.com/billing) to any paid ngrok account. | ||
|
||
For more information and examples, please see the interstitial explanation [here](https://ngrok.com/docs/guides/limits/#why-is-there-an-interstitial-in-front-of-my-html-content). | ||
|
||
If you are the Administrator for this account, and none of these steps work for you or you have additional questions, drop us a note at at [[email protected]](mailto:[email protected]?subject=Help%20with%20ngrok%203200%20error). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,62 @@ | ||
--- | ||
title: Fast API | ||
title: FastAPI | ||
--- | ||
|
||
# Using ngrok with FastAPI | ||
|
||
If you're looking to natively embed the ngrok agent into your Fast API application, you can leverage the [pyngrok project](https://pyngrok.readthedocs.io/en/latest/integrations.html#fastapi) to start a tunnel anytime you start the FastAPI Server via uvicorn. | ||
You can leverage the [ngrok-python](https://github.com/ngrok/ngrok-python) library to embed the ngrok agent in to FastAPI Applications. | ||
|
||
:::warning | ||
ngrok-python and FastAPI libraries used in this example are sensitive to versions. Use of Virtual Environments is highly recommended | ||
::: | ||
|
||
```sh | ||
# requirements.txt | ||
ngrok==1.3.0 | ||
uvicorn==0.29.0 | ||
fastapi==0.111.0 | ||
loguru==0.7.2 | ||
``` | ||
|
||
```sh | ||
pip install -r requirements.txt | ||
``` | ||
|
||
```python | ||
# main.py | ||
from contextlib import asynccontextmanager | ||
from os import getenv | ||
|
||
import ngrok | ||
import uvicorn | ||
from fastapi import FastAPI | ||
from loguru import logger | ||
|
||
NGROK_AUTH_TOKEN = getenv("NGROK_AUTH_TOKEN", "") | ||
NGROK_EDGE = getenv("NGROK_EDGE", "edge:edghts_") | ||
APPLICATION_PORT = 5000 | ||
|
||
# ngrok free tier only allows one agent. So we tear down the tunnel on application termination | ||
@asynccontextmanager | ||
async def lifespan(app: FastAPI): | ||
logger.info("Setting up Ngrok Tunnel") | ||
ngrok.set_auth_token(NGROK_AUTH_TOKEN) | ||
ngrok.forward( | ||
addr=APPLICATION_PORT, | ||
labels=NGROK_EDGE, | ||
proto="labeled", | ||
) | ||
yield | ||
logger.info("Tearing Down Ngrok Tunnel") | ||
ngrok.disconnect() | ||
|
||
|
||
app = FastAPI(lifespan=lifespan) | ||
|
||
@app.get("/") | ||
async def root(): | ||
return {"message": "Hello World"} | ||
|
||
if __name__ == "__main__": | ||
uvicorn.run("main:app", host="127.0.0.1", port=APPLICATION_PORT, reload=True) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters