Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Kestrel considers Connection: keep-alive, upgrade as non-upgrade request #1170

Closed
analogrelay opened this issue Oct 17, 2016 · 9 comments
Closed
Assignees
Milestone

Comments

@analogrelay
Copy link
Contributor

Firefox sends it's WebSocket upgrade request with a Connection header value of keep-alive, Upgrade. Unfortunately MessageBody.For does a strict equality check (https://github.com/aspnet/KestrelHttpServer/blob/dev/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/MessageBody.cs#L237) which means the WebSocket request is assigned the ForContentLength version, with a content length of 0. As a result, the connection is considered terminated before it is even established and things go haywire (specifically the first attempt to Receive a message causes an exception because the underlying connection has been terminated).

We'll need to switch to either a Contains check or multiple Equals checks in order to ensure we're getting things right.

/cc @halter73

@Tratcher
Copy link
Member

WebListener probably has the same bug.

@cesarblum cesarblum added the bug label Oct 17, 2016
@analogrelay
Copy link
Contributor Author

This is pretty high priority since it means Firefox can't establish a WebSocket connection to Kestrel. /cc @Eilon @muratg

@analogrelay
Copy link
Contributor Author

Yeah, it definitely seems like we're in good company :). Best to be willing to accept it on the server though.

@analogrelay
Copy link
Contributor Author

Yep, saw that in my work porting that over to Sockets. I'll make the fix there as well.

@shirhatti
Copy link

@jhkimnew Can you check if this breaks IIS/ANCM as well?

@BrennanConroy
Copy link
Member

No, firefox works fine with the server behind IIS/ANCM

@analogrelay
Copy link
Contributor Author

analogrelay commented Oct 18, 2016

In that case, because IIS is establishing the connection to Kestrel, it is fine because IIS uses Connection: Upgrade on the outbound request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants