@@ -748,6 +748,7 @@ def __init__(self, app):
748748 'GCLOUD_PROJECT environment variable.' )
749749 self ._fcm_url = _MessagingService .FCM_URL .format (project_id )
750750 self ._client = _http_client .JsonHttpClient (credential = app .credential .get_credential ())
751+ self ._timeout = app .options .get ('httpTimeout' )
751752
752753 @classmethod
753754 def encode_message (cls , message ):
@@ -760,7 +761,7 @@ def send(self, message, dry_run=False):
760761 if dry_run :
761762 data ['validate_only' ] = True
762763 try :
763- resp = self ._client .body ('post' , url = self ._fcm_url , json = data )
764+ resp = self ._client .body ('post' , url = self ._fcm_url , json = data , timeout = self . _timeout )
764765 except requests .exceptions .RequestException as error :
765766 if error .response is not None :
766767 self ._handle_fcm_error (error )
@@ -791,7 +792,12 @@ def make_topic_management_request(self, tokens, topic, operation):
791792 url = '{0}/{1}' .format (_MessagingService .IID_URL , operation )
792793 try :
793794 resp = self ._client .body (
794- 'post' , url = url , json = data , headers = _MessagingService .IID_HEADERS )
795+ 'post' ,
796+ url = url ,
797+ json = data ,
798+ headers = _MessagingService .IID_HEADERS ,
799+ timeout = self ._timeout
800+ )
795801 except requests .exceptions .RequestException as error :
796802 if error .response is not None :
797803 self ._handle_iid_error (error )
0 commit comments