View Issue Details

IDProjectCategoryView StatusLast Update
0004996libmicrohttpdcompliancepublic2017-05-28 22:50
Reporterdohmniq Assigned ToKarlson2k  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.53 
Target Version0.9.55Fixed in Version0.9.55 
Summary0004996: websockets fail with Microsoft Edge network error 12152
DescriptionSome of my users are complaining of this error when using Edge to connect websockets:

SCRIPT12152: WebSocket Error: Network Error 12152, The server returned an invalid or unrecognized response

My application's HTTP response headers are:

Connection: Keep-Alive
Connection: Upgrade
Content-Type: text/html; charset=UTF-8
Date: Mon, 24 Apr 2017 13:01:36 GMT
Sec-WebSocket-Accept: 3SN9SihJt1Slc2C1bY0PscTQegc=
Sec-WebSocket-Protocol: updates
Transfer-Encoding: chunked
Upgrade: Websocket

[Copy & paste from Chrome developer console. I added a space after each header name's colon for readability.]

Note how libmicrohttpd is responding with two "Connection:" headers.
TagsNo tags attached.

Activities

dohmniq

2017-04-24 18:44

reporter   ~0012064

Possibly suspect calls to keepalive_possible() in connection.c

BTW, keepalive_possible() itself segfaults if you queue a response (e.g. a 404) to websocket request because connection->response is NULL at line 885 in this snippet:

#ifdef UPGRADE_SUPPORT
    if ( (MHD_str_equal_caseless_ (end,
                                   "upgrade")) &&
         (NULL == connection->response->upgrade_handler) )
      return MHD_NO;
#endif /* UPGRADE_SUPPORT */

dohmniq

2017-05-04 11:00

reporter   ~0012098

See also bug 5003

Karlson2k

2017-05-05 20:17

manager   ~0012109

Thanks for report!
Seems that it's time to write function to properly process all headers and values.
Currently MHD use only first value in first header with specific name.

Karlson2k

2017-05-06 11:44

manager   ~0012111

Looks like this request is violation of RFC 7230.
https://tools.ietf.org/html/rfc7230#section-3.2.2 :
"A sender MUST NOT generate multiple header fields with the same field name in a message unless either the entire field value for that header field is defined as a comma-separated list [i.e., #(values)] or the header field is a well-known exception (as noted below)."
However MHD will support it.

dohmniq

2017-05-07 10:34

reporter   ~0012112

In case of any confusion the HTTP headers with two "Connection:" entries listed in the original description are the from MHD's *response* (to Edge's websocket request).

I'm noting this because you said "request" in your last note and "However MHD will support it" seems to imply (to me at least!) that you're thinking that the issue is to do with headers that MHD is receiving, not sending which is the actual issue.

Just wanted to make sure you're not doing a whole load of work on a misunderstanding! Also apologies if I'm the one in the wrong here.

Thanks

Karlson2k

2017-05-09 22:19

manager   ~0012122

Thanks for clarifying.

Could you try MHD from git master?

dohmniq

2017-05-11 10:56

reporter   ~0012126

I updated to latest MHD from git master but even without using Edge browser I'm still seeing multiple "Connection:" response headers:

== Response Headers from MHD ==

Connection: close
Connection: Upgrade
Content-Type: text/html; charset=UTF-8
Date: Thu, 11 May 2017 08:49:37 GMT
Sec-WebSocket-Accept: EYSrKIitViAF9F4BxI3D6bLO+yA=
Sec-WebSocket-Protocol: updates
Upgrade: Websocket


== Request Headers from Chrome ==

Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Cache-Control: no-cache
Connection: Upgrade
Host: [removed]
Origin: [removed]
Pragma: no-cache
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Sec-WebSocket-Key: Ub5vQGJEpIJwAe+ECmF+/w==
Sec-WebSocket-Protocol: updates
Sec-WebSocket-Version: 13
Upgrade: websocket
User-Agent: Mozilla/5.0 (X11; FreeBSD amd64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

Karlson2k

2017-05-11 11:41

manager   ~0012127

At least we removed irrelevant "Transfer-Encoding".
Will look at code.

Karlson2k

2017-05-11 13:52

manager   ~0012128

Updated once more.
Could you try again with commit 787bfd1859db22c58271f287dfcb505c0052edd3?

dohmniq

2017-05-11 14:05

reporter   ~0012129

Confirmed working -- thanks!

Karlson2k

2017-05-11 14:28

manager   ~0012130

Thanks for report!
Could you copy here resulting request and response headers?

Issue History

Date Modified Username Field Change
2017-04-24 15:11 dohmniq New Issue
2017-04-24 18:44 dohmniq Note Added: 0012064
2017-05-04 11:00 dohmniq Note Added: 0012098
2017-05-04 22:46 Christian Grothoff Assigned To => Karlson2k
2017-05-04 22:46 Christian Grothoff Status new => assigned
2017-05-04 22:46 Christian Grothoff Target Version => 0.9.55
2017-05-05 20:17 Karlson2k Note Added: 0012109
2017-05-06 11:44 Karlson2k Note Added: 0012111
2017-05-07 10:34 dohmniq Note Added: 0012112
2017-05-09 22:19 Karlson2k Note Added: 0012122
2017-05-11 10:56 dohmniq Note Added: 0012126
2017-05-11 11:41 Karlson2k Note Added: 0012127
2017-05-11 13:52 Karlson2k Note Added: 0012128
2017-05-11 14:05 dohmniq Note Added: 0012129
2017-05-11 14:28 Karlson2k Note Added: 0012130
2017-05-11 14:30 Karlson2k Reproducibility have not tried => always
2017-05-11 14:30 Karlson2k Status assigned => resolved
2017-05-11 14:30 Karlson2k Resolution open => fixed
2017-05-11 14:30 Karlson2k Fixed in Version => 0.9.55
2017-05-28 22:50 Christian Grothoff Status resolved => closed