question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RedirectResponse to service hosted on a container timing out

See original GitHub issue

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn’t find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google “How to X in FastAPI” and didn’t find any information.
  • I already read and followed all the tutorial in the docs and didn’t find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

@app.get("/container/somepath")
async def container():
   return RedirectResponse("https://10.0.0.4:10401/somepath")

Description

I’m having an issue redirecting the request using the containers’ IP, the request it redirected but the response times out. I’m not sure if this can be fixed from my FastAPI project or from my server setup, but when testing with curl on the server, I get the right response data.

I am running a number of containers on a server, behind a reverse proxy which is running in another container. My FastAPI project is stored on the host, but the requests go through the reverse proxy container, where the FastAPI socket is mapped and consumed by nginx.

In the API, when I do a RedirectResponse using the host IP I get a response, but I would like to use the containers’ IP instead. The containers’ IP are not visible on the LAN (only from host or between them), but I can access them through port forwarding. If I manage to redirect using the internal IPs, I would remove port forwarding, and access these services through my FastAPI project,

The problem is that even though I can curl an endpoint from a container on the host or on the reverse proxy container using the internal IPs, the redirection is not working through FastAPI. Is there something I’m missing? Not sure what else I can do to debug this.

Operating System

Linux

Operating System Details

No response

FastAPI Version

0.73.0

Python Version

3.9

Additional Context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
jgould22commented, Feb 1, 2022

That is good.

One note, you will want to use a async http client. Requests is sync so your process will stop at that call and not work on other things.

0reactions
xiki808commented, Feb 1, 2022

Appreciate that tip, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot HTTP 307 errors in Amazon S3
When I send requests to an Amazon Simple Storage Service (Amazon S3) bucket, Amazon S3 returns a 307 Temporary Redirect response.
Read more >
Azure SignalR Service internals | Microsoft Learn
Self-hosted ASP.NET Core SignalR application server listens to and connects clients directly. With SignalR Service, the application server ...
Read more >
Redirect or rewrite requests :: Gloo Mesh Enterprise Docs
Overwrites the host portion of the URL with another host. Optionally adds a redirect response code. After the original host and path are...
Read more >
dockerd - Docker Documentation
Usage: dockerd COMMAND A self-sufficient runtime for containers. ... support --shutdown-timeout int Set the default shutdown timeout (default 15) -s, ...
Read more >
Virtual Service - Istio
Access model - Applications address only the destination service (Host) without ... The following VirtualService sets a timeout of 5s for all calls...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found