skip to Main Content

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?

3

Answers


  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

    Login or Signup to reply.
  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.

    Login or Signup to reply.
  3. Your bot should store last update_id, Then compare by update_id

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search