To use the WebSocket protocol on a route, cache must be disabled because WebSocket is incompatible with buffering, which is a requirement for the router caching.
"https://{default}/ws":
type: upstream
upstream: "myapp:http"
cache:
enabled: falseLet’s break this down.
-
"https://{default}/ws":-
https://- since there's nohttp://route configured,http://will automatically redirect tohttps://. -
{default}tells Upsun to use the default domain assigned to your project. This is especially useful if your project doesn't have a domain added yet. That said, you could type a static value such asmy-domain.com -
/ws- you’re telling Upsun that any request to/ws(https://{default}/ws) should be handled by this route definition. If your development environment was sending websocket requests to e.g.https://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 change this. This just lets Upsun know how we're going to handle requests. -
upstream: "myapp:http"- This works with
type: upstreamto let Upsun know which app you want to answer this request.- In your
.upsun/config.yamlyou will have defined a value likename: myapporname: my-symfony-app. Use whatever valuename:is. In other words, if you usename: my-websocket-app, then in yourroutes.yamlyou will useupstream: "my-websocket-app:http
- In your
- This works with
Once you have this route pointing to your websocket app, you will want to handle the next step, request buffering.
Comments
Please sign in to leave a comment.