How to Debug Webhooks
May 6, 2022Debugging webhooks can be tricky, there are a few places the problem could be, and its not easy to tell which problems you might have.
There might might be a problem with any of..
- Triggering the webhook
- Sending the webhook over the internet
- An error in your server
This article will guide you through the steps to debug your webhook and get your data flowing.
Is the webhook sending?
First check if the webhook messages were event sent. Some webhook providers have a view in their webhook settings that shows when recent messages were sent. For example Github has this view.
Make sure the webhook is being sent when you think it should be. Usually webhooks are event based, there is some trigger, if possible change the trigger to be something you can fire on command or something that happens frequently.
Carefully read the documentation paying attention to the definition of the events that should be triggering the webhook.
Is there a network problem?
For the webhook to reach your server you typically need it to be reachable on the public internet.
You can check this by trying to reach it from your web browser, you might get a 404 Not-Found or 400 Bad-Request error, which show you can reach the server. If you get a Site-Cannot-Be-Reached error, it means you have a network problem. You can also check with a website like portcheckers.com to check if its reachable from another server.
You can also do Packet Capture on your server to try and see if the webhook requests are hitting it. You could do this with a tool like Wireshark or Tcpdump. For example if your server was running on port 80 and the webhook url was "/incoming-webhook" you would run. Trigger the webhook while running the packet capture and see if you can see the requests, also see if the response is there it might also indicate an a problem.
$ tcpdump port 80 | grep -C 10 "POST /incoming-webhook"
Is your server failing to process the webhook?
If you can see the webhook messages coming into the server but it looks like nothing is happening, it means your server isnt processing it. Check your logs and see if there are any errors. Check if there is an http status code. It could be that there is a 500 internal server error, or a 400 bad request error. Perhaps the format of the webhook doesnt match the programmed expected format.
It might help to test that the server processes a webhook message by sending one via
curl
curl -X POST localhost:80/incoming-webhook -H 'application/json' -d '{"message": "test"}'
Still struggling?
If your still having trouble you can use webhook wizard to help debug the webhook. You can configure the webhook to send to webhook wizard where it will log the requests and send them to your server retrying if there is a problem.
If you would like to hear more about webhook wizard and how it can help you please subscribe to update.
Subscribe