'Calling ngrok url(my localhost to ngrok) in python requests going infinite
I want to integrate a webhook in my Django application that supports only HTTPS requests. I want to test in my local machine so here I am using ngrok to make my localhost HTTPS i.e. https://c71e-2415-201-138f-ad9d-3005-825a-23c9-c788.ngrok.io/
and my local URL is
http://localhost:8000
I created a URL in my application named call_webhook_internally and related views.py function is
@csrf_exempt
def call_webhook_internally(request):
try:
ng_rok_url = https://c71e-2415-201-138f-ad9d-3005-825a-23c9-c788.ngrok.io/
url = ng_rok_url + "call_webhook/"
headers = {
"Timestamp": str(datetime.utcnow()),
}
payload = json.loads(request.body)
response = requests.request("POST", url, headers=headers, data=payload)
return HttpResponse("success")
except Exception as e:
return HttpResponse("Error")
the upper function is calling and when my request is called to call webhook using python it blocks the main thread and postman goes in an infinite loop, in ngrok terminal I am getting that request is received but in function, my print statement is not printing. I want to call my internal webhook in my existing app views.py function is call_webhook i.e.
def call_webhook_internally(request):
print(request)
return HttpResponse("webhook_called")
After 10-15 minutes getting error i.e.
webhook failed. Error HTTPSConnectionPool(host='c10e-2105-215-138f-ad9d-3005-825a-23c9-c788.ngrok.io',
port=443): Max retries exceeded with url: /call_webhook/ (Caused by SSLError(SSLError("read error:
Error([('SSL routines', 'ssl3_get_record', 'decryption failed or bad record mac')],)",),))
so pls suggest to me some way to do this is am I doing something wrong?
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
