Skip to content

Commit 74e99f4

Browse files
committed
Fixed webhook connection
1 parent dbfac18 commit 74e99f4

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

whatsapp_api_client_python/tools/webhooks.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ class Webhooks:
1111
def __init__(self, api: "GreenApi"):
1212
self.api = api
1313

14-
self.api.session.headers["Connection"] = "keep-alive"
15-
1614
@property
1715
def started(self) -> Optional[bool]:
1816
"""Deprecated"""
@@ -67,6 +65,8 @@ def job(self, onEvent: Callable[[str, dict], Any]) -> None:
6765
print("Stopped receiving incoming notifications.")
6866

6967
def _start_polling(self, handler: Callable[[str, dict], Any]) -> None:
68+
self.api.session.headers["Connection"] = "keep-alive"
69+
7070
self.api.logger.log(
7171
logging.INFO, "Started receiving incoming notifications."
7272
)
@@ -90,6 +90,8 @@ def _start_polling(self, handler: Callable[[str, dict], Any]) -> None:
9090
except KeyboardInterrupt:
9191
break
9292

93+
self.api.session.headers["Connection"] = "close"
94+
9395
self.api.logger.log(
9496
logging.INFO, "Stopped receiving incoming notifications."
9597
)

0 commit comments

Comments
 (0)