You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm using Ariadne on my application and so far everything seems to be working normally, but recently the websocket handlers seem to have stopped working.
This is the code I'm using
Im running the following code using poetry ( poetry run python3 main.py )
import uvicorn
import asyncio
from ariadne.asgi import GraphQL
from ariadne.asgi.handlers import GraphQLTransportWSHandler
from ariadne import MutationType, make_executable_schema
from starlette.applications import Starlette
from starlette.routing import WebSocketRoute
type_defs = """
type Query {
_unused: Boolean
}
type Message {
sender: String
message: String
}
type Mutation {
send(sender: String!, message: String!): Boolean
}
type Subscription {
message: Message
}
"""
mutation = MutationType()
schema = make_executable_schema(type_defs, mutation)
graphql_handler = GraphQL(
schema=schema,
debug=True,
websocket_handler=GraphQLTransportWSHandler(),
logger="admin.graphql"
)
routes = [
WebSocketRoute("/api/graphqlws", endpoint=graphql_handler),
]
app = Starlette(routes=routes)
async def main():
config = uvicorn.Config("main:app", port=8000, log_level="info")
server = uvicorn.Server(config)
await server.serve()
if __name__ == "__main__":
asyncio.run(main())
When I try to open a new websocket connection (opening a new browser window and using new WebSocket('ws://localhost:8000/api/graphqlws'); ).
it does not seem to be working. This is the output I'm seeing:
Database URL already set
postgresql+psycopg2://postgres:postgres@localhost:5432/reactivebb
INFO: Started server process [6869]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: ('127.0.0.1', 63746) - "WebSocket /api/graphqlws" [accepted]
INFO: connection open
INFO: connection closed
Is there something I'm doing wrong?
Note: running this without the following lines
async def main():
config = uvicorn.Config("main:app", port=8000, log_level="info")
server = uvicorn.Server(config)
await server.serve()
if __name__ == "__main__":
asyncio.run(main())
And using poetry run uvicorn main:app produces the same output.
I also have this problem on a larger application I'm building, which uses apollo and graphql but I'm guessing this is the same problem.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I'm using Ariadne on my application and so far everything seems to be working normally, but recently the websocket handlers seem to have stopped working.
This is the code I'm using
Here's my pyproject.toml (list of packages):
Im running the following code using poetry (
poetry run python3 main.py
)When I try to open a new websocket connection (opening a new browser window and using
new WebSocket('ws://localhost:8000/api/graphqlws');
).it does not seem to be working. This is the output I'm seeing:
Is there something I'm doing wrong?
Note: running this without the following lines
And using
poetry run uvicorn main:app
produces the same output.I also have this problem on a larger application I'm building, which uses apollo and graphql but I'm guessing this is the same problem.
Beta Was this translation helpful? Give feedback.
All reactions