Azure / azure-relay-dotnet

☁️ .NET Standard client library for Azure Relay Hybrid Connections
https://docs.microsoft.com/en-us/azure/service-bus-relay/relay-what-is-it
MIT License
37 stars 33 forks source link

The server returned status code '400 This endpoint is only for web-socket requests' when status code '101' was expected #135

Open geo-the-dude opened 4 years ago

geo-the-dude commented 4 years ago

Actual Behavior

The Relay Proxy is deployed in a network with strict firewall policies. To get the Relay working, ProxyCap was used. However, when initializing the connection the following error appears:

Microsoft.Azure.Relay.RelayException: BadRequest: This endpoint is only for web-socket requests. 

System.Net.WebSockets.WebSocketException: The server returned status code '400 This endpoint is 
only for web-socket requests' when status code '101' was expected.

The proxy enabled all outbound and inbound connections for the exe for port 443. We have also tried to enable it for all ports with no avail.

Expected Behavior

  1. The Relay Proxy should be able to listen to the requests even if it is behind a proxy.

Versions

dlstucki commented 4 years ago

We return this error message when our HTTP stack (.NET HttpListener) reports a new connection where HttpListenerRequest.IsWebSocketRequest is false.

The way I've seen this happen in the past is when one or more of the HTTP headers to make a websocket connection are missing. I think any of these 4 headers missing will result in that error code/description:

Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Key: II0Pdyw7LfFtmBU7keD7Iw==
Sec-WebSocket-Version: 13

Is there any way to get a trace of the initial HTTP request which gets sent to the relay cloud service? (Are you using WcfRelays or HybridConnections? Are you using an old SDK for WcfRelays?)

geo-the-dude commented 4 years ago

Hi dlstucki, we will try to utilize fiddler to trace the HTTP requests. We are currently utilizing Azure Relay Hybrid Connections. We are currently using the Microsoft.Relay 2.0.0-preview1 nuget package.