Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
bug: APNS may close a socket prematurely, resulting in an AttributeError
Browse files Browse the repository at this point in the history
Updates some reqs

closes #862
  • Loading branch information
jrconlin committed Apr 7, 2017
1 parent 1f3c3b2 commit ed86e26
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 4 additions & 1 deletion autopush/router/apns2.py
Expand Up @@ -124,6 +124,9 @@ def send(self, router_token, payload, apns_id,
# re-established.
stream_id = connection.request(
'POST', url=url, body=body, headers=headers)
# get_response() may return an AttributeError. Not really sure
# how it happens, but the connected socket may get set to None.
# We'll treat that as a premature socket closure.
response = connection.get_response(stream_id)
if response.status != 200:
reason = json.loads(response.read().decode('utf-8'))['reason']
Expand All @@ -135,7 +138,7 @@ def send(self, router_token, payload, apns_id,
"your message {}".format(reason),
log_exception=False
)
except HTTP20Error:
except (HTTP20Error, AttributeError):
connection.close()
raise
finally:
Expand Down
2 changes: 1 addition & 1 deletion autopush/router/apnsrouter.py
Expand Up @@ -142,7 +142,7 @@ def _route(self, notification, router_data):
try:
apns_client.send(router_token=router_token, payload=payload,
apns_id=apns_id)
except ConnectionError as ex:
except (ConnectionError, AttributeError) as ex:
self.ap_settings.metrics.increment(
"updates.client.bridge.apns.connection_err",
self._base_tags
Expand Down
12 changes: 6 additions & 6 deletions requirements.txt
Expand Up @@ -6,20 +6,20 @@ autobahn[twisted]==0.16.0
boto==2.42.0
boto3==1.4.0
botocore==1.4.50
cffi==1.7.0
cffi==1.10.0
click==6.6
contextlib2==0.5.4
cryptography==1.7.2
cryptography==1.8.1
cyclone==1.1
datadog==0.13.0
decorator==4.0.10
enum34==1.1.6
future==0.15.2
futures==3.0.5
gcm-client==0.1.4
hyper==0.6.2
idna==2.1
ipaddress==1.0.16
hyper==0.7.0
idna==2.5
ipaddress==1.0.18
jmespath==0.9.0
marshmallow==2.10.2
marshmallow_polyfield==3.1
Expand All @@ -32,7 +32,7 @@ pycrypto==2.6.1
pyfcm==1.0.4
python-dateutil==2.5.3
raven==5.25.0
requests==2.11.0
requests==2.13.0
service-identity==16.0.0
simplejson==3.8.2
six==1.10.0
Expand Down

0 comments on commit ed86e26

Please sign in to comment.