Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSockets not closed gracefully #1770

Closed
Tratcher opened this issue Jun 22, 2022 · 0 comments
Closed

WebSockets not closed gracefully #1770

Tratcher opened this issue Jun 22, 2022 · 0 comments
Assignees
Labels
Type: Bug Something isn't working
Milestone

Comments

@Tratcher
Copy link
Member

Tratcher commented Jun 22, 2022

Describe the bug

After the client and server have exchanged graceful WS Close messages, YARP isn't gracefully closing the connection. After a few seconds the client times out and closes the connection. This causes the client (E.g. Chrome) to report a WS error (1006) rather than a graceful close (1000).

To Reproduce

  1. Create a WebSocket connection through YARP
  2. Close it gracefully from both sides
  3. Observe a multi-second pause and then the client disconnects and may report an error

This reproduces with YARP running on Kestrel, HttpSys, and IIS Express. The client can be chrome, edge or even HttpClient, though that doesn't report an error.

It also reproduces in our WebSocket functional tests, causing them to take 1s or longer, vs a few ms when I tell YARP to cancel the request read.

public async Task WebSocketTest(WebSocketMessageType messageType)

I think the problem is here:

var (secondResult, secondException) = await secondTask;

After the client and destination have exchanged close messages the destination closes the connection. YARP sees the response copy complete, but then waits for the request side to be closed from the client. Instead it should cancel the ongoing read.

Further technical details

Version: 1.1
Reported by an internal partner

Recommend we patch this in 1.1

@Tratcher Tratcher added the Type: Bug Something isn't working label Jun 22, 2022
@Tratcher Tratcher self-assigned this Jun 22, 2022
@karelz karelz added this to the YARP 1.1.x milestone Jun 23, 2022
Tratcher added a commit that referenced this issue Jun 23, 2022
Tratcher added a commit that referenced this issue Jun 24, 2022
Tratcher added a commit that referenced this issue Jul 1, 2022
Tratcher added a commit that referenced this issue Jul 1, 2022
Tratcher added a commit that referenced this issue Nov 1, 2022
Tratcher added a commit that referenced this issue Nov 2, 2022
@Tratcher Tratcher closed this as completed Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants