Greetings,
It seems like webhooks have an internal timeout were, if the endpoint takes too much time sending a response, it tries again and sends another request.
Is there a way to adjust the timeout or disable this behaviour?
Thanks in advance for your answer.
PD: My test endpoint is on ngrok, and i added a timeout of 10s for testing this.
there is no such feature. timeout is set to 5
. retries are set to 3
.
if you wish you can add configuration field on webhook and use it in requests and send a pull request.
https://requests.readthedocs.io/en/latest/user/advanced/#timeouts
code that will change:
for i in range(3):
try:
r = requests.request(
method=webhook.request_method,
url=webhook.request_url,
data=json.dumps(data, default=str),
headers=headers,
timeout=5,
)
r.raise_for_status()
frappe.logger().debug({"webhook_success": r.text})
log_request(webhook.request_url, headers, data, r)
break
except requests.exceptions.ReadTimeout as e:
frappe.logger().debug({"webhook_error": e, "try": i + 1})
log_request(webhook.request_url, headers, data)
except Exception as e:
frappe.logger().debug({"webhook_error": e, "try": i + 1})
This file has been truncated. show original
Oh, alright, I just wanted to make sure before trying something in the code. Thanks.