2

Websocket Redirect

I have two services, one have a websocket server on it for live transcription , but the client can only connect with the first one. What I want to do is in the following image : ws_redirect

I checked the documentation, and the closest I can get is from the RedirectResponse section :

from fastapi import FastAPI
from fastapi.responses import RedirectResponse

app = FastAPI()


@app.get("/typer")
### Websocket Redirect
I have two services, one have a websocket server on it for live transcription , but the client can only connect with the first
async def read_typer():
    return RedirectResponse("https://typer.tiangolo.com")

I would apperciate any help. Thank you !

Hosten
  • 138
  • 1
  • 11
  • Perhaps it will be helpful https://stackoverflow.com/questions/65361686/websockets-stream-audio-in-json-out-w-fastapi-and-two-websockets/65395702 – alex_noname Jun 09 '21 at 12:50
  • Thx @alex_noname, but this is the solution I want to avoid. I don't want the gateway to intercept the data. Just redirect the URL to another one. – Hosten Jun 09 '21 at 13:15
  • You cannot really do it without some form of intercepting. HTTP redirects won't allow you to pass the data from resource directly inaccessible for user, as they are browser based. – GwynBleidD Jun 09 '21 at 14:59
  • Does this answer your question? [Websockets bridge for audio stream in FastAPI](https://stackoverflow.com/questions/65361686/websockets-bridge-for-audio-stream-in-fastapi) – GwynBleidD Jun 09 '21 at 15:00
  • I want to leave bridge as a last resort. I will try using a proxy server atm, maybe it will do. – Hosten Jun 10 '21 at 13:45

0 Answers0