dapr with websockets on azure container apps

Lokesh Royal 0 Reputation points
2023-01-16T11:50:00.1866667+00:00

Hi, currently im using azure container apps for our application deployment with dapr we are using react as frontend and nodejs as backend. hear im facing a issue with websocket invoke all the api's are working fine but websocket connections are not working fine, websocket connection is getting created but in next few seconds its getting disconnected. below is config file of nginx where routing is configured

server {
listen 5002;
listen [::]:5002;
server_name default server;

location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    try files $uri  /index.html;
}

location /ws {
            proxy pass http://localhost:3500/v1.0/invoke/backend/method/ws;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header Host $host;
    }


location /api/v1 {
    proxy pass http://localhost:3500/v1.0/invoke/backend/method/api/v1;
}



2023-01-16T10:21:28.772170573Z Mon Jan 16 2023 10:21:28 GMT+0000 (Coordinated Universal Time) Connection accepted.
2023-01-16T10:21:38.774068619Z reason is :  1006
Mon Jan 16 20
Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
48 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Urnun 5,026 Reputation points Microsoft Employee
    2023-01-23T18:42:46.9866667+00:00

    Hello @Lokesh Royal - Thank you for posting on MS Q&A!

    On the Azure Containers Apps side for supporting WebSocket, it sounds like you already have the correct configuration with the transport type set to either auto or http, ref: Set up HTTPS or TCP ingress in Azure Container Apps

    Assuming that you have it configured so and the fact that the WebSocket connection is being established, I believe the root cause may have to do with the reason is : 1006 error which is missing the actual reason message. I've come across this post on StackOverflow with many people weighing in on Close Code 1006 caused by Abnormal Closure by the client browser which appears to be common with Chromium-based browsers. In your case though, I'd try increasing the nginx default timeout per this answer, and if that doesn't resolve the issue, I'd start debugging the client side and the front-end code. Feel free to tag me, and let me know how it goes, and I'd be happy to help!

    No comments