aiogram-template icon indicating copy to clipboard operation
aiogram-template copied to clipboard

webhooks using

Open mixartemev opened this issue 3 years ago • 5 comments

It's the best template for aiogram3.0 I could find! But can you please to privide minimal example within webhook updates?

mixartemev avatar Feb 07 '22 14:02 mixartemev

I've implemented webhooks as it is shown at aiogram3.0 example but in this case mongo fsm storage is crashes due to some low-level asynchronous things that I didn't understand, with error: RuntimeError: Task <Task pending name='Task-11' coro=<BaseRequestHandler._background_feed_update() running at /Volumes/Home/Library/Caches/pypoetry/virtualenvs/aiogram-template-VZ-Pzham-py3.10/lib/python3.10/site-packages/aiogram/dispatcher/webhook/aiohttp_server.py:124>> got Future <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/local/Cellar/[email protected]/3.10.1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/futures.py:384]> attached to a different loop Screenshot 2022-02-08 at 12 17 38 But still it's working fine with other fsm storages like redis. So I'm curious how to fix working with mongo storage because it's actually pretty convenient way to use fsm storage.

mixartemev avatar Feb 08 '22 09:02 mixartemev

It's the best template for aiogram3.0 I could find! But can you please to privide minimal example within webhook updates?

Hi! I have never implemented webhooks in aiogram 3. Maybe I will in the future.

rdfsx avatar Feb 12 '22 08:02 rdfsx

I've implemented webhooks as it is shown at aiogram3.0 example but in this case mongo fsm storage is crashes due to some low-level asynchronous things that I didn't understand, with error: RuntimeError: Task <Task pending name='Task-11' coro=<BaseRequestHandler._background_feed_update() running at /Volumes/Home/Library/Caches/pypoetry/virtualenvs/aiogram-template-VZ-Pzham-py3.10/lib/python3.10/site-packages/aiogram/dispatcher/webhook/aiohttp_server.py:124>> got Future <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/local/Cellar/[email protected]/3.10.1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/futures.py:384]> attached to a different loop Screenshot 2022-02-08 at 12 17 38 But still it's working fine with other fsm storages like redis. So I'm curious how to fix working with mongo storage because it's actually pretty convenient way to use fsm storage.

I think this is because storage is implemented without real locks, but using asyncio Lock instead. I have not tried to implement locks in mongo yet, so I advise you to use either redis or polling

rdfsx avatar Feb 12 '22 08:02 rdfsx

Are you sure you need webhooks? In my experience, the only time they're useful is when you're highloading and need to proxy requests to multiple bot instances. But I mean really high load

rdfsx avatar Feb 12 '22 08:02 rdfsx