opened
thombrink
username_0
### Describe the bug
When sending a websocket request through the proxy, it fails at `StreamCopier.CopyAsync` in the `CopyResponseBodyAsync` method of the `HttpProxy` class.

### To Reproduce
1. Start `ReverseProxy.Direct.Sample` and `SampleServer`.
2. Request a websocket connection on the `ReverseProxy.Direct.Sample` and redirect it to the `SampleServer` `/api/websockets` endpoint.

The output will show: `Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets: Debug: Connection id "<connection_id>" received FIN.` and `Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets: Debug: Connection id "<connection_id>" sending FIN because: "The client closed the connection."`.

When `SampleServer` is called directly, it all works like expected.

### Further technical details

- Tested on the current main branch
- The used platform: Windows
Proxy websocket request exception
issue
created
Tratcher
username_1
Is that error reported from the proxy process or the SampleServer? It claims the client disconnected.

Here are some diagnostics you can collect and/or share to help narrow it down:
- Full debug logs from the proxy process
- Wireshark/network traces between the proxy and client
- Any client logs you can collect
comment
created
Tratcher
username_1
I ran this with the TestClient, ReverseProxy.Direct.Sample, and SampleServer and it seems to behave as expected:

I see these logs:
```
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET https://localhost:5001/api/websockets - -
dbug: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[0]
      Wildcard detected, all requests with hosts will be allowed.
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1001]
      1 candidate(s) found for the request path '/api/websockets'
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1005]
      Endpoint '/{**catch-all}' with route pattern '/{**catch-all}' is valid for the request path '/api/websockets'
dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[1]
      Request matched endpoint '/{**catch-all}'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint '/{**catch-all}'
info: Yarp.ReverseProxy.Service.Proxy.HttpProxy[9]
      Proxying to http://localhost:5002/api/websockets?area=xx2
dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[6]
      Connection id "0HM84AMCB38HE" received FIN.
dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7]
      Connection id "0HM84AMCB38HE" sending FIN because: "The client closed the connection."
dbug: Microsoft.AspNetCore.Server.Kestrel[10]
      Connection id "0HM84AMCB38HE" disconnecting.
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint '/{**catch-all}'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 GET https://localhost:5001/api/websockets - - - 101 - - 1583.0792ms
dbug: Microsoft.AspNetCore.Server.Kestrel[2]
      Connection id "0HM84AMCB38HE" stopped.
```

Receiving a FIN is a normal part of the WebSocket close process, not an error condition.

I don't see any errors reported in StreamCopier, what was the error?
comment
closed
Tratcher
username_1
issue
created
Tratcher
username_1
Closing. Let us know if you find additional information.
comment