android-sms-gateway icon indicating copy to clipboard operation
android-sms-gateway copied to clipboard

Webhooks errors

Open vitalyKl opened this issue 3 months ago • 5 comments

Describe the Bug Hello! Sometimes the gateway fails sending vebhook updates. In thew logs there are 2 notifications:

  1. Webhook failed with retry: Job was cancelled
  2. Empty payload.

The issue may appear twice a day, may not appear. Restarting the app solves the problem, but the issue reproduces again later.

To Reproduce Just send/receive SMS.

Expected vs Actual Behavior

  • Expected: The gateway sends updates via webhooks.
  • Actual: Sometimes webhooks don't work.

Screenshots If applicable, add screenshots to help explain your problem.

Environment

  • App Version: 1.50.0 (1206)
  • Mode: Cloud
  • Operation: sending and receiving SMS
  • Integration: API
  • Network Type: WiFi

Smartphone

  • Device: Huawei P20 Lite
  • OS: Android 9
  • SIM Card Count: 1

Checklist Before Submission

  • [+ ] I have described the bug in detail.
  • [ +] I have provided the steps to reproduce.
  • [ -] I have included screenshots (if applicable).
  • [ +] I have provided environment details.
  • [ -] I have included relevant log file excerpts (if applicable).
  • [ +] I have read FAQ and other relevant information.

vitalyKl avatar Oct 31 '25 06:10 vitalyKl

Hello!

Thank you for your detailed bug report.

Could you please provide the following:

  1. Logs from the Local Server API as described in the documentation: https://docs.sms-gate.app/features/logging/#accessing-logs
  2. Your cloud account username.
  3. How many webhooks are currently registered?

If you prefer not to share the logs here, you can send them via email to [email protected]

capcom6 avatar Oct 31 '25 12:10 capcom6

Hello!

  1. Logs are attached. Phone numbers and url of service are masked. I think, it's better to look into the logs afet 2025-10-28.
  2. 2KVRSN
  3. 4 that are working and 2 were registered just for test.

And sometimes the webhooks send data, that have been already sended to the application. That is why there are a lot of rows with status code 4**. I've fixed it on my side, to notify the gateway with status code 200.

logs.csv

vitalyKl avatar Nov 03 '25 06:11 vitalyKl

Thank you for providing the logs and the additional details.

Based on my analysis, here is an explanation of the issues you're encountering:

  1. Regarding "Job was canceled": This occurs when your server does not consistently respond with a 2xx status code or fails to respond at all. When this happens, the app places the webhook in a retry queue. Any new events also enter this retry loop, and if the queue's capacity is exceeded, some tasks may be canceled.

  2. Regarding "Empty payload": For multipart messages, an sms:delivered event is triggered for each part. If a webhook gets stuck in the retry loop and is eventually canceled, it removes the source event information from storage. Consequently, a subsequent webhook for another part of the same message can fail with an "Empty payload" error.

  3. Regarding event deduplication: The app may send a webhook with the same messageId for different parts of a multipart message. However, it should never send a webhook with the same root id if the previous one was confirmed with a 2xx code. Could you please clarify if you are receiving duplicate values in the root id field or in the messageId?

Recommendations:

  • Improve the connection stability between your device and server.
  • Ensure your endpoint responds with a 2xx status code for every event within 30 seconds.
  • Consider reducing the retry count to 1 or 2 in the app's settings to help manage the queue.

On my side, I will review the webhook retry logic to prevent these issues.

For your reference, please see our documentation:

  • https://docs.sms-gate.app/features/webhooks/#step-5-receive-the-payload
  • https://docs.sms-gate.app/features/webhooks/#multipart-message-behavior

capcom6 avatar Nov 03 '25 09:11 capcom6

Thank you for your reply.

I just want to bring there more clearance: our app does not send multipart messages and does not receive those. We use gateway for communication with GPS-trackers. I believe the biggest message may contain about 150 characters. That is why there are no realized logic for multi-part messages. We do not need them.

The server responds to webhooks with an interval of 30 seconds, but the gateway rarely interrupts the connection quickly:

Image

vitalyKl avatar Nov 04 '25 11:11 vitalyKl

Hello!

Thank you for the clarification.

Based on the logs, I can see there are numerous network issues (connection timeouts) and server errors (400/401 status codes). These underlying problems are preventing the webhooks from functioning reliably and make it difficult to isolate the specific bug you reported.

To move forward, please focus on stabilizing the connection between the gateway and your server. Once the network is reliable and your server consistently returns 2xx responses, I can examine new logs to identify the core issue in isolation.

Thank you for your understanding and cooperation.

capcom6 avatar Nov 04 '25 22:11 capcom6