Infente Loop (SSE) Event for Safari Server

I'm having problems with Server Submission (SSE) events in Safari 9 and Safari 10. An SSE connection opens, closes immediately, and then reconnects in an endless loop.

This is client side code:

var events = new EventSource("/stream/events")

These are the HTTP response headers:

> GET /stream/events HTTP/1.1
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Cache-Control: no-cache
< Connection: keep-alive
< Content-Type: text/event-stream
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Last-Modified: Tue, 19 Sep 2017 05:28:22 GMT
< Strict-Transport-Security: max-age=31536000
< X-Accel-Buffering: no
< X-Content-Type-Options: nosniff
< X-Frame-Options: DENY
< X-Xss-Protection: 1; mode=block
< Date: Tue, 19 Sep 2017 05:28:22 GMT
< Transfer-Encoding: chunked

Some additional notes:

  • I tested in Chrome and Firefox and cannot repeat
  • I tested in Safari without https and cannot repeat
  • I tested in Safari with https and could repeat
  • Https certificates are automatically generated using Lets Encrypt
  • The backend server is written in Go and uses http / 2 by default.

, Safari https. , - SSE https, - , .

. http2 , . http2 , .

:

--- before.go   2017-09-19 13:31:45.668891000 -0400
+++ after.go    2017-09-19 13:31:55.100891000 -0400
@@ -2,6 +2,6 @@
            Addr: ":443",
            TLSConfig: &tls.Config{
                GetCertificate: manager.GetCertificate,
-               NextProtos:     []string{"h2", "http/1.1"},
+               NextProtos:     []string{"http/1.1"},
            },
        }
+4

Source: https://habr.com/ru/post/1685928/


All Articles