reactjsazuredockerwebsocketguacamole

Failed to forward request using WebSockets


I am trying to open a WebSocket tunnel from a React frontend to an Azure App Service running a Docker image. The Docker image is a simple .NET Core 7.0 application which supports WebSockets. The tunnel is initiated from guacamole-common-js library. Opening a tunnel from Postman works, but not in the browser. I have looked into CORS and AllowedOrigin, but without any solution.

The logs on Azure shows the following:

Failed to forward request to http://172.16.0.2. Encountered a System.Net.WebSockets.WebSocketException exception after 33.194ms with message: The server returned status code '403' when status code '101' was expected.. Check application logs to verify the application is properly handling HTTP traffic.

Guacamole is returning error code 519.

Any ideas what could cause this problem? I'm not sure this is an Azure issue, because I have also tried running the Docker image on another host without luck. The application works as expected when running locally (Not containerized).

Regular HTTP GET requests to the service from the React frontend works fine.


Solution

  • I have identified the problem. Initially, we attempted to set AllowedOrigins on WebSocketOptions by using environment variables. However, for some unknown reason, this approach did not work. After confirming that no AllowedOrigin values were set, I was able to resolve the issue and get it working.