-
Notifications
You must be signed in to change notification settings - Fork 72
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
Mounting app on different path does not seem to work #186
Comments
I usually avoid using relative path in application. Did you try using module path as reference ? import uvicorn
import streamsync.serve
from fastapi import FastAPI, Response
import os.path
app_dir = os.path.dirname(__file__)
root_asgi_app = FastAPI()
sub_asgi_app_1 = streamsync.serve.get_asgi_app(app_dir, "run")
root_asgi_app.mount("/hello", sub_asgi_app_1)
@root_asgi_app.get("/")
async def init():
return Response("""
<h1>Welcome to the App Hub</h1>
""")
uvicorn.run(root_asgi_app,
host="0.0.0.0",
port=5328,
log_level="warning",
ws_max_size=streamsync.serve.MAX_WEBSOCKET_MESSAGE_SIZE) |
Are you saying that that works for you? I still get the same error....The relative path was taken from your example doc, so figured that that was OK to use.. |
My bad, I didn't test the correct behavior. I confirm it doesn't work. The problem is due to I have find a hack to make it work. I forward the lifespan from subapplication to main application You will rely on fastapi internal, I can't garantee it will work after update. We have to discuss with @ramedina86 on a change to expose lifespan properly to streamsync developper and update the documentation. import uvicorn
import streamsync.serve
from fastapi import FastAPI, Response
import os.path
app_dir = os.path.dirname(__file__)
sub_asgi_app_1 = streamsync.serve.get_asgi_app(app_dir, "run")
root_asgi_app = FastAPI(lifespan=sub_asgi_app_1.router.lifespan_context)
root_asgi_app.mount("/hello", sub_asgi_app_1)
@root_asgi_app.get("/")
async def init():
return Response("""
<h1>Welcome to the App Hub</h1>
""")
uvicorn.run(root_asgi_app,
host="0.0.0.0",
port=5328,
log_level="warning",
ws_max_size=streamsync.serve.MAX_WEBSOCKET_MESSAGE_SIZE) |
This works great...Thanks! Now I have to figure out how to make this work with a reverse proxy, since I am having issues with NGINX, but that is likely separate issue. |
I am getting a "Connection rejected" error from streamsync when I put my app behind a reverse proxy, but only if I use the different mount point as we discussed above. When my app is just at the root, the authentication and app works fine, so we are still not out of the woods...Any ideas about this issue? Is this an nginx issue or still something with FastAPI? |
I have tried a configuration using nginx as reverse proxy. It is working fine for me. here is the reverse proxy configuration I have used nginx/conf.d/default.conf server{
listen 8080;
location / {
proxy_pass http://app:5328;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
} docker-compose version: "3.9"
services:
app:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./src/:/app/src
init: true
reverse_proxy:
image: nginx:latest
ports:
- 8080:8080
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d Dockerfile FROM python:3.10 as builder
RUN mkdir -p /app
WORKDIR /app
RUN pip3 install poetry
COPY . /app
RUN poetry install --without dev
FROM python:3.10-bullseye as base
COPY --from=builder /app /app
RUN groupadd --gid 1000 user && \
useradd --create-home -u 1000 -g 1000 user && \
chown -R user:user /app
USER user
WORKDIR /app
ENV PATH="/app/.venv/bin:$PATH"
CMD ["python", "src/app/webapp.py"]
#CMD ["streamsync","--host", "0.0.0.0", "--port", "5328", "edit", "src/app"] |
the issue is when you mount the app on a different path... server{
listen 8080;
location /hello {
proxy_pass http://app:5328;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
} And use the mount trick you showed earlier... I am running it on a https server with authentication. I'll see if I can make a reproducible version of it, but since it requries certificates etc. and PAM authentication, not sure that it is easy...But I will start with the docker example you gave |
Did you check if you have any info when you enable complete logging on nginx ? Could you share logs with us ? Could you also post a screenshot of the network section of your developer tools with the page that fails ? |
Thanks...I got it to work..It WAS an issue with my NGINX configuration, so all good now! |
Hey @thondeboer apologies for being unresponsive and I'm very happy to hear you still like Streamsync. No need to worry about its future, though I appreciate the concern. In fact, I've been busy preparing for the next stage; I'll be working full time on this. |
Awesome, thanks for allaying my fears :) I have been creating some custom components (IGV Genome browser and a server-side dataframe) and have more ideas...Some way to easily install custom components as a pacakge would be a great help and if there was a way to make custom components be globally available (as part of ss on a local server, rather than copying the dist folder to each app that needs it) would be a great addition and the basis for a great plugin infrastructure...
Regards,
Thon
…On 1/4/24 2:19 PM, Ramiro Medina ***@***.***> wrote:
Hey @thondeboer <https://github.com/thondeboer> apologies for being
unresponsive and I'm very happy to hear you still like Streamsync. No
need to worry about its future, though I appreciate the concern. In
fact, I've been busy preparing for the next stage; I'll be working full
time on this.
—
Reply to this email directly, view it on GitHub
<#186 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AA2DU3NHXWAIJBBHK7UNTS3YM4TGPAVCNFSM6AAAAABA4AMA4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZXHAZTMMRXGY>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@FabienArcellier thought the same and developed an extension mechanism which is very much in line with what you mentioned. Here's the PR if you're curious #166 This is still being refined but coming rather soon. |
Hi, loving the streamsync and somewhat worried that it has been quiet for a while on the release front here...hope you have not lost interest! This is my favorite webapp dev tool since it is sooo easy to get something working...Have also developed a couple of custom components...
anyhoo...
I am trying to mount an app under a different path and followed the directions on the custom server section of the docs, but I am getting a
In the browser and this in the logs:
This is the (only slightly modified example) for server.py
I used the default app hello and placed the serve.py in the same directory and also tried different locations, but always the same result. THe fastAPI is running I am pretty sure, since I get the welcome message, but the path /hello gets the error.
Thanks again for this great app!
The text was updated successfully, but these errors were encountered: