Telegram sends duplicate POST JSON requests to webhook

匿名 (未验证) 提交于 2019-12-03 01:20:02

问题:

I am trying to develop city bot for telegram, but meet a problem. After sending message to bot, Telegram sends 2 duplicate requests to a webhook url. Webhook script works twice and sends twice responses to user. Script - hellobot.php from official telegram docs. Server vps hosting with self-signed SSL, with uploaded cert key to telegram.

From server logs.

149.154.167.209 - - [28/Jun/2016:13:48:00 +0300] "POST /apps/gate.php HTTP/1.0" 200 86 "-" "- 149.154.167.209 - - [28/Jun/2016:13:48:00 +0300] "POST /apps/gate.php HTTP/1.1" 200 86 "-" "- 149.154.167.209 - - [28/Jun/2016:13:48:00 +0300] "POST /apps/gate.php HTTP/1.0" 200 86 "-" "- 149.154.167.209 - - [28/Jun/2016:13:48:00 +0300] "POST /apps/gate.php HTTP/1.1" 200 86 "-" "-

How to fix this?

回答1:

Could you post some code;

If you are asking to getupdates and send response to user upon each result ; it may send the duplication because you did not set the offset right

offset (Description): Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. ...

#getupdates_offset



回答2:

when Telegram receive a message from your bot user, send the message to your webhook URL in JSON format.

if

  1. occurs an error in your response page,
  2. or take very long time to finish the response,

then Telegram send the message to your server again.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!