Skip to content

Mounting app on different path does not seem to work #186

@thondeboer

Description

@thondeboer

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

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

In the browser and this in the logs:

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/fastapi/applications.py", line 1106, in __call__
    await super().__call__(scope, receive, send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 443, in handle
    await self.app(scope, receive, send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/fastapi/applications.py", line 1106, in __call__
    await super().__call__(scope, receive, send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 274, in app
    raw_response = await run_endpoint_function(
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/streamsync/serve.py", line 122, in init
    response = await app_runner.init_session(InitSessionRequestPayload(
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/streamsync/app_runner.py", line 668, in init_session
    return await self.dispatch_message(None, InitSessionRequest(
  File "/home/tdeboer/.cache/pypoetry/virtualenvs/dash-bio-B22Gy4nA-py3.10/lib/python3.10/site-packages/streamsync/app_runner.py", line 611, in dispatch_message
    raise ValueError(
ValueError: Cannot dispatch message. No connection to AppProcess server is set.

This is the (only slightly modified example) for server.py

import uvicorn
import streamsync.serve
from fastapi import FastAPI, Response

root_asgi_app = FastAPI()
sub_asgi_app_1 = streamsync.serve.get_asgi_app(".", "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)

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions