'HttpClient timeout on Braintree call in Blazor

I'm deploying my .Net 6, Blazor Server site for the first time on shared hosting. It's all seems to work so far bar two things.

In the browser console (Chrome) I get an error:

Error 1
blazor.server.js:1 WebSocket connection to 'wss://www.mysite.co.uk/_blazor?id=qW5eCRVc_HbgSWt8iESawA' failed: 
Information: (WebSockets transport) There was an error with the transport.
Error: Failed to start the transport 'WebSockets': Error: WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.
Warning: Failed to connect via WebSockets, using the Long Polling fallback transport. This may be due to a VPN or proxy blocking the connection. To troubleshoot this, visit https://aka.ms/blazor-server-using-fallback-long-polling.

The page seems to work & I've added all the CSP entries I can find so that's the only error left.

Error 2 is when I call Braintree to capture a payment. That's the only Braintree call & it works fine locally.

Transaction.SubmitForSettlementAsync(transactionId, amount)
gets an exception : The request was canceled due to the configured HttpClient.Timeout of 60 seconds elapsing.

I have no idea why that is & assume is blocking is call. Any help would be appreciated.



Solution 1:[1]

For this warning:

Warning: Failed to connect via WebSockets, using the Long Polling fallback transport. This may be due to a VPN or proxy blocking the connection. To troubleshoot this, visit https://aka.ms/blazor-server-using-fallback-long-polling.

see: https://docs.microsoft.com/en-us/aspnet/core/signalr/publish-to-azure-web-app?view=aspnetcore-5.0#configure-the-app-in-azure-app-service

For apps hosted without the Azure SignalR Service, enable:

  • ARR Affinity to route requests from a user back to the same App Service > instance. The default setting is On.
  • Web Sockets to allow the Web Sockets transport to function. The default setting is Off.
  1. In the Azure portal, navigate to the web app in App Services.
  2. Open Configuration > General settings.
  3. Set Web sockets to On.
  4. Verify that ARR affinity is set to On.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 juFo