Http/2 connection terminated

I'm trying to have an open connection with my server over http/2 to send requests using URLSession. I want to it open for a long time (30 minutes or so). I enabled cfnetwork debug and I see in the log after a few minutes of idle:


CFNetwork Diagnostics [3:1445] 16:28:33.612 {

h2 frame: (null)

h2 : [17] sent [35;1mGOAWAY[0m frame<length=8, flags=0x0, stream_id=0>

h2 gowy: [17] (last_stream_id=0, error_code=Success(0), opaque_data_len=0)

} [3:1445]


My understanding is that CFNetwork closes the connection by sending a GOAWAY message to the server. I'm trying to figure out how to prevent this or understand why it is sent at that time. This is ios 11.4. Any help is appreciated.


Thank you!


-Yuval

I want to it open for a long time (30 minutes or so).

CFNetwork uses an idle timer to ‘garbage collect’ idle connections. The exact timeout varies by platform (macOS vs iOS-based platforms), interface (WWAN vs Wi-Fi), and protocol type (HTTP/2 vs HTTP 1.1), but they are all much shorter than 30 minutes. Moreover, this value is not configurable.

The only direct workaround I’m aware of is to write (or acquire) your own HTTP/2 client code. Needless to say this won’t be a lot of fun. If you do go down this path please make sure to file an enhancement request against

NSURLSession
asking for a configurable timeout, and explaining why such a long timeout is necessary.

You should also take a look at push notifications to see if you can remove the need for this requirement entirely.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Http/2 connection terminated
 
 
Q