devlikeapro / waha

WAHA - WhatsApp HTTP API (REST API) that you can configure in a click! Two engines: chromium-based WEBJS and pure-websocket NOWEB
https://waha.devlike.pro/
Apache License 2.0
944 stars 283 forks source link

Getting all chats is failed each time because of Timeout error [BUG][WEBJS] - #278

Closed dolevhayut closed 3 months ago

dolevhayut commented 6 months ago

When calling endpoint /api/{session}/chats its failed each time when you have a lot of chats. timeout is few minutes and failed also in the swagger environment as well

{ "version": "2024.3.6", "engine": "WEBJS", "tier": "PLUS", "browser": "/usr/bin/chromium" }

attached screenshot from console image

patron:PLUS

allburov commented 6 months ago

Hi! That endpoint can work pretty slow, because it's unusual behaviour for WhatsApp Web client to get all chats. Consider listen to incoming messages and save information about chats to your database so you can get the list of recent chats quickly waha.devlike.pro/docs/how-to/receive-messages

We'll double check it anyway

dolevhayut commented 6 months ago

Thank you Yes after many attempts that was the method I worked with finally.

בתאריך יום ג׳, 19 במרץ 2024, 04:37, מאת allburov @.***

:

Hi! That endpoint can work pretty slow, because it's unusual behaviour for WhatsApp Web client to get all chats. Consider listen to incoming messages and save information about chats to your database so you can get the list of recent chats quickly waha.devlike.pro/docs/how-to/receive-messages

— Reply to this email directly, view it on GitHub https://github.com/devlikeapro/whatsapp-http-api/issues/278#issuecomment-2005641528, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3AE2JDYFYZAVR5MQKCLESDYY6QGFAVCNFSM6AAAAABE4HNU7GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBVGY2DCNJSHA . You are receiving this because you authored the thread.Message ID: @.***>

patron:PLUS

allburov commented 6 months ago

@dolevhayut it seems to be an issue in Swagger UI - could you try get it using curl or your favorite language to issue GET http://localhost:3000/api/default/chats request

Swagger endpoint doesn't work for me too, but that one get me all my chats pretty fast!

curl -X 'GET' \
  'http://localhost:3000/api/default/chats' \
  -H 'accept: */*'

Keep in mind that there's a limit in about 5000 chats anyway (it comes from WhatsApp Web itself), so if you have more - it'll likely return only 5000 chats to you

devlikepro commented 3 months ago

Added limit and offset parameters to GET /api/{session}/chats endpoint.


Get all chats

Get all chats

GET /api/{session}/chats

If you see timeout or the request takes too long - consider using limit parameter to get chats in smaller chunks

GET /api/{session}/chats?limit=100&offset=0

patron:PRO

dolevhayut commented 3 months ago

Amazing! Thanks for that, what about channel ( newsletter ) endpoints?

בתאריך יום ב׳, 17 ביוני 2024, 07:02, מאת devlikeapro ‏< @.***>:

Added limit and offset parameters to GET /api/{session}/chats endpoint.


Get all chats

Get all chats

GET /api/{session}/chats

  • limit - limit the number of chats to return
  • offset - skip the number of chats from the start

If you see timeout or the request takes too long - consider using limit parameter to get chats in smaller chunks

GET /api/{session}/chats?limit=100&offset=0


[image: patron:PRO] https://waha.devlike.pro/docs/how-to/plus-version/#tiers

— Reply to this email directly, view it on GitHub https://github.com/devlikeapro/waha/issues/278#issuecomment-2172156271, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3AE2JHYSPJ3EBNP4JW43N3ZHZNVTAVCNFSM6AAAAABE4HNU7GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZSGE2TMMRXGE . You are receiving this because you were mentioned.Message ID: @.***>

patron:PLUS