Reputation: 340
I know this is a duplicate of Telegram sends duplicate POST JSON requests to webhook and Telegram sends duplicate POST JSON requests to webhook. However, there wasn't any adequate answer to this question, so:
I have a PHP app handling webhook requests from Telegram. However, Telegram fails to read that webhook worked successfully (although hurl.it shows clearly it sends 200 back on such a request).
Therefore, I have my bot reply a message loads of times because Telegram just won't get that the message is handled yet.
The problem is also described here (the lib I'm using):
https://github.com/irazasyed/telegram-bot-sdk/issues/23
However, no definite answer there either...
How can I fix it?
1) My bot is using a webhook 2) It definitely returns 200 OK response 3) User receives replies from the bot UPDATE 4) It's not a timeout.
My getWebhookInfo
response:
[decodedBody:protected] => Array
(
[ok] => 1
[result] => Array
(
[url] => https://bots.chatforge.me/t/test
[has_custom_certificate] =>
[pending_update_count] => 3
[last_error_date] => 1514900657
[last_error_message] => Unsupported Media Type: unsupported content-encoding
[max_connections] => 40
)
)
Upvotes: 3
Views: 8258
Reputation: 6556
If Telegram received HTTP 200 in a timely manner it won't repeat the request. My guess is your request/response is timing out. Use getwebhookinfo to see what was your last request error and update question if it's not a time out.
Seems problem is something about Content-encoding header. I suggest posting some fake data to you bot and see what Content-encoding header you receive. Use the curl I found in https://core.telegram.org/bots/webhooks or use Postman like programs.
curl -v -k -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
"update_id":10000,
"message":{
"date":1441645532,
"chat":{
"last_name":"Test Lastname",
"id":1111111,
"type": "private",
"first_name":"Test Firstname",
"username":"Testusername"
},
"message_id":1365,
"from":{
"last_name":"Test Lastname",
"id":1111111,
"first_name":"Test Firstname",
"username":"Testusername"
},
"text":"/start"
}
}' "https://YOUR.BOT.URL:YOURPORT/"
Upvotes: 5