How to setup Ratchet Websocket server on production for Symfony app
Permanently deleted user
Hello,
I am trying to setup a Ratchet Websocket server on my Symfony app for production environment.
Didn’t find any reliable documentation about the subject, I have several questions :
- According to https://docs.platform.sh/define-routes.html#websocket-routes I must define routes in
.platform/routes.yaml for websocket, but I have actually no idea what values I should put there :
"https://{default}/ws": # is that some default route ? Should I set it in my app router too ?
type: upstream
upstream: "ws-app:http" #what exactly is ws-app ? Should I have a separated app ?
cache:
enabled: false
Knowing that locally the server works fine via ws://127.0.0.1:8080
- How to actually start the server in production ? Should I add something in my deploy scripts ?
Should I use RabbitMQ or something similar ? Do I need a worker ?
Thanks for your help!
0
Comments
Let’s break this down.
"https://{default}/ws":https://- since you don’t have ahttp://route configured,http://will automatically redirect tohttps://.{default}tells platform.sh to use your default domain assigned to the project. This is good to have in place, especially if you haven’t attached a domain yet. That said, you could type a static value such asmy-domain.com/ws- You’re telling Platform.sh that any request to/ws(https://{default}/ws) should be handled by this route definition. If you’re development environment was sending websocket requests tohttp://localhost/my/websocket, you should replace/wswith/my/websocket. Use the path that your app is configured to work with.type: upstream- normally you won’t mess with this. This just let’s Platform.sh know that we are going to direct this to the app that you have defined.upstream: "ws-app:http"type: upstreamto let Platform.sh know which app you want to answer this request.ws-app:http- the first part of this is what matters—thews-app. In your.platform.app.yamlor in your.platform/applications.yamlyou will have defined an value likename: apporname: my-symfony-app. Whatever the value ofname:is, that should be the first part of this value. In other words, if you usename: my-websocket-app, then in your routes.yaml you will use:upstream: "my-websocket-app:httpOnce you have this route pointing to your websocket app, you will want to handle the next step, request buffering.
Please sign in to leave a comment.