mozilla-services / autopush

Python Web Push Server used by Mozilla
https://autopush.readthedocs.io/
Mozilla Public License 2.0
217 stars 34 forks source link

bug: Add connection timeouts for APNS #1394

Closed jrconlin closed 4 years ago

jrconlin commented 4 years ago

Closes #1393

Description

I don't believe that these connections are being closed, and eventually we wind up with old, mostly idle connections that Apple frowns upon. Also, APNS is not really "heavy use" so we can probably turn off the pre-connection pool and just connect when need be.

TODO: find a better reaper than just calling out to Thread.

Testing

There are unit tests. With debugging enabled, idle connections should time out after about 5 min.

Issue(s)

Closes #1393.

codecov-commenter commented 4 years ago

Codecov Report

Merging #1394 into master will decrease coverage by 0.01%. The diff coverage is 97.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1394      +/-   ##
==========================================
- Coverage   99.74%   99.72%   -0.02%     
==========================================
  Files          64       64              
  Lines       10476    10537      +61     
==========================================
+ Hits        10449    10508      +59     
- Misses         27       29       +2     
Impacted Files Coverage Δ
autopush/router/apns2.py 98.07% <95.65%> (-1.93%) :arrow_down:
autopush/router/apnsrouter.py 100.00% <100.00%> (ø)
autopush/tests/test_router.py 99.90% <100.00%> (+<0.01%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 00aaab4...0e494b9. Read the comment docs.

jrconlin commented 4 years ago

NOTE: going to ice this PR for the time being.

After discussions with @pjenvey, this hack may work, but what's really needed is more visibility into whatever error may actually be occurring. The HTTP2 library we use is fairly robust and should be able to handle any invalid state naturally.

Keeping this PR and branch in reserve in case it's needed.