Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for not found token : bot_token #6

Open
mrabedini opened this issue Jul 6, 2017 · 11 comments
Open

Request for not found token : bot_token #6

mrabedini opened this issue Jul 6, 2017 · 11 comments

Comments

@mrabedini
Copy link

mrabedini commented Jul 6, 2017

First, I should thank you for your great app. In polling mode on my local machine the module works like charm. However when I use the web hook mode, sometimes I get the

Request for not found token : bot_token

error and no response is given by the bot. I didn't setup the cert file in my settings.py . I am using nginx with combination of gunicorn to serve my web app. The server os is ubuntu 16.04. Below is the settings I've used:

DJANGO_TELEGRAMBOT = {
    'MODE' : 'WEBHOOK', #(Optional [str]) # The default value is WEBHOOK,
                        # otherwise you may use 'POLLING'
                        # NB: if use polling you must provide to run
                        # a management command that starts a worker
    'WEBHOOK_SITE' : 'https://www.shipup.ir',
    'WEBHOOK_PREFIX' : '/telegram-bot/', # (Optional[str]) # If this value is specified,
                                  # a prefix is added to webhook url
   # 'WEBHOOK_CERTIFICATE' : '', # If your site use self-signed
                         #certificate, must be set with location of your public key
                         #certificate.(More info at https://core.telegram.org/bots/self-signed )
    'BOTS' : [
        {
           'TOKEN': 'bot_token', #Your bot token.
        },
    ],
}

The thing that intrigues is the point that sometimes my bot works. Any advice to solve the issue is appreciated.

@mrabedini
Copy link
Author

with some logging, I've found that in some requests that there is no response of the bot, the cls.bot_tokens is empty.

@mrabedini
Copy link
Author

I found the problem. In gunicorn the number of workers were set to 3. Just one of them could have bot_tokens and two of them didn't have the tokens. When I set the number of workers to 1, everything is ok.
Now the question is what should I do to get it to work with number of workers 3 in gunicorn.

@JungDev
Copy link
Owner

JungDev commented Jul 10, 2017

Can you try to comment this line https://github.com/JungDev/django-telegrambot/blob/master/django_telegrambot/apps.py#L126 , please?

@mrabedini
Copy link
Author

Yes, it solved the problem. What the line is for?!

@JungDev
Copy link
Owner

JungDev commented Jul 10, 2017

It's a flag to prevent re-running code which should be executed exactly one time.

@mrbf
Copy link

mrbf commented Sep 23, 2017

I have the same problem. The settings is:

DJANGO_TELEGRAMBOT = {
    'MODE' : 'WEBHOOK', 
    'WEBHOOK_SITE' : 'https://example.com/',
    'BOTS' : [
        {
           'TOKEN': 'botToken',
        },
    ],
}

I commented the apps.py 126th line and restarted server. But problem still exist.
Logging says that 'Not Found: /botToken/'.
How can I solve the issue?

marqueewinq added a commit to marqueewinq/django-telegrambot that referenced this issue Oct 13, 2017
@marqueewinq
Copy link

@JungDev @mrabedini Ok, that's what i found

This error is mainly caused by TelegramError (Flood control), which is caused by rapid setWebhook queries.
Perhaps, if bot.getWebhookInfo().url != hookurl: <set webhook> check will help.

marqueewinq added a commit to marqueewinq/django-telegrambot that referenced this issue Oct 13, 2017
@mrabedini
Copy link
Author

mrabedini commented Oct 22, 2017

It seems that the problem still remains. When I use gunicorn with supervisor, I have the same issue.
I tried to regenerate the issue with docker. Using gunicorn with --bind option and nginx serving the requests didn't have any problem. My next try would be to add supervisor to the simulation.
However, as I mentioned earlier in the current comment, on the server I still have the problem.

@aliaksandrmelnik
Copy link

aliaksandrmelnik commented Jan 23, 2018

This error raise with uWSGI too.

Looks like MR #10 fix this problem.

@rafis
Copy link
Contributor

rafis commented May 28, 2018

Agree with @aliaksandrmelnik, most commonly encountered issue is telegram.error.RetryAfter: Flood control exceeded. Retry in 1 seconds.

esabunor added a commit to doalier/django-telegrambot that referenced this issue Jul 31, 2018
@heykarimoff
Copy link

@mrabedini Had the same problem with gunicorn. Setting --workers=1 helped.

@JungDev Is PR #8 going to be the only solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants