Skip to main content

How to setup Ratchet Websocket server on production for Symfony app

Comments

1 comment

  • Tyler Mills
    "https://{default}/ws":
        type: upstream
        upstream: "ws-app:http"
        cache:
            enabled: false
    

    Let’s break this down.

    1. "https://{default}/ws":
      • https:// - since you don’t have a http:// route configured, http:// will automatically redirect to https://.
      • {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 as my-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 to http://localhost/my/websocket, you should replace /ws with /my/websocket. Use the path that your app is configured to work with.
    2. 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.
    3. upstream: "ws-app:http"
      • This works with type: upstream to let Platform.sh know which app you want to answer this request.
      • ws-app:http - the first part of this is what matters—the ws-app. In your .platform.app.yaml or in your .platform/applications.yaml you will have defined an value like name: app or name: my-symfony-app. Whatever the value of name: is, that should be the first part of this value. In other words, if you use name: my-websocket-app, then in your routes.yaml you will use: upstream: "my-websocket-app:http

    Once you have this route pointing to your websocket app, you will want to handle the next step, request buffering.

    0

Please sign in to leave a comment.