Websocket connection is failing

Hi,

We are building an application that needs to be deployed on the cloud (Azure/AWS). It’s a React application and it uses the Ledger API to pull the information from DAML Ledgers.

In localhost, the application works perfectly without any issues. While we deploy the application in Azure/AWS virtual machines, we are getting the below error,

"WebSocket connection to ‘ws://x.x.x.x:7575/v1/stream/query’ failed: "
“useStreamQuery: WebSocket connection failed.”

This is the blocker for us and can someone help us to move forward.

Thanks in advance.

Is there some type of proxy like nginx or a load balancer or something similar involved in your setup?

Nope, @cocreature . We have deployed both DAML and React APP in a single Ubuntu Azure VM. We have exposed port 3000 to the react application and rest of the DAML API’s running it in default ports like 7500 for navigator, 6865 for sandbox, 7575 for WS.

As stated in the documentation,

Your JSON API service should never be exposed to the internet. When running in production the JSON API should be behind a reverse proxy, such as via NGINX.

For this reason, the JSON API binds to localhost, disallowing remote connections and yielding your error. We strongly recommend configuring a [HTTPS-secured] reverse proxy instead of attempting to connect directly to JSON API from a remote host.

2 Likes

It may not fit your use-case directly, but the Auth0 setup documentation page has an example nginx configuration which should provide a good starting point. This is towards the end; you can ignore all of the Auth0 setup if you’re not planning to use that.