whatsapp-http-api icon indicating copy to clipboard operation
whatsapp-http-api copied to clipboard

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

Open dolevhayut opened this issue 11 months ago • 3 comments

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

dolevhayut avatar Mar 18 '24 19:03 dolevhayut

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

allburov avatar Mar 19 '24 02:03 allburov

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

dolevhayut avatar Mar 19 '24 11:03 dolevhayut

@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

allburov avatar Mar 22 '24 11:03 allburov

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

  • Read more about Get all chats
  • Build: 2024.6.4
  • Engine: WEBJS
  • Engine: NOWEB

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

patron:PRO

devlikepro avatar Jun 17 '24 04:06 devlikepro

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

dolevhayut avatar Jun 17 '24 14:06 dolevhayut