Testing Anymail webhook locally, unable to receive signal

398 Views Asked by At

I am trying to test my setup for Anymail (using Mailgun) webhooks. Currently using https://ngrok.com/ which redirects an HTTPS address to a local address to properly handle localhost:80 addresses.

Mailgun allows to send test requests to a webhook, which points to the temporary ngrok provided addres, something like:

https://random:[email protected]/webhooks/anymail/mailgun/tracking/

Following anymail-webhooks the app is currently able to actually receive the webhook call as shown in the logs:

web          | "POST /webhooks/anymail/mailgun/tracking/ HTTP/1.1" 200 0

The response code 200 indicates the backend received the webhook correctly and sent an acknowdledge.

The url is set here:

path('webhooks/anymail/', include('anymail.urls')),

and the signal receiver is as simple as:

from anymail.signals import tracking
from django.dispatch import receiver

@receiver(tracking)
def handle_signal(sender, event, esp_name, **kwargs):
    print('[ --- ] {}'.format(event))

I expect to see something in my shell for every POST to /webhooks/anymail/mailgun/tracking/ but apparently the receiver is never receiving the signal and thus not printing anything.

I went over this a couple of times and I can't figure what am I missing.

0

There are 0 best solutions below