-
Notifications
You must be signed in to change notification settings - Fork 123
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
Bug:Channel is not accessible when setup_state=False #989
Comments
@kgadek93 you just forgot to setup your router with FastAPI lifespan. It is an important part (and, unfortunatelly, required one) until tiangolo doesn't merge this PR Correct code shoud looks like: from fastapi import FastAPI
from faststream.rabbit.fastapi import RabbitRouter
router = RabbitRouter(...)
app = FastAPI(..., lifespan=router.lifespan_context) # you forgot about this one
app.include_router(router, ...) |
Hi, @Lancetnik I've check that and I've added lifespan like this: app = FastAPI(
title="my-service",
middleware=middlewares,
version=settings.RELEASE_VERSION,
dependencies=[Depends(initialize_context)],
lifespan=Lifespans([database_lifespan, import_router.lifespan_context]),
) but I still see this issue:
|
Read the error message, please. You are trying to connect to not-existed RMQ instance |
hi, |
Nope, but you can create your custom lifespan and start broker manually to reach that behavior |
ok @Lancetnik I get it, thank you for your reply |
Describe the bug
Channel is not accessible when setup_state=False.
When i try to publish message i see this error:
"RabbitBroker channel is not started yet". Here is full traceback:
How to reproduce
Include source code:
And/Or steps to reproduce the behavior:
Expected behavior
Explain what you expected to happen clearly and concisely.
Message should be added successfully to queue.
Observed behavior
Message wasn't added into the queue and it's raising an error.
Screenshots
If applicable, attach screenshots to help illustrate the problem.
Environment
Include the output of the
faststream -v
command to display your current project and system environment.I'm using faststream so i run server like that:
uvicorn main_fastapi:app --host 0.0.0.0 --reload --port 9080
Additional context
Provide any other relevant context or information about the problem here.
The text was updated successfully, but these errors were encountered: