Baileys icon indicating copy to clipboard operation
Baileys copied to clipboard

Fixing Timed Out error on connection initialization

Open laxeder opened this issue 1 year ago • 4 comments

Fixes the timed out error when initializing the connection, this error occurs because when connecting, a query is sent to the socket, which in turn breaks the application when it fails.

The solution suggested in the code is to close the connection in case of an error instead of popping the error.

laxeder avatar Jan 21 '24 03:01 laxeder

Thanks for your contribution.

The next step is to wait for review and approval to merge it to main repository

The community can help reacting with a thumb up (:thumbsup:) for approval and rocket (:rocket:) for who has tested it.

To test this PR you can run the following command below:

# NPM
npm install @whiskeysockets/baileys@laxeder/Baileys#master
# YARN v2
yarn add @whiskeysockets/baileys@laxeder/Baileys#master

whiskeysockets-bot avatar Jan 21 '24 03:01 whiskeysockets-bot

Good work, though its better to know what is causing this error and preventing that instead of try-catching it. Though in general we should have some hook that catches any errors and closes the connection instead of crashing your app, that is out of the scope of this issue.

True, this error occurred to me here when finishing the connection sock.end(...) and right after triggering the connection closed event, reconnecting by recreating the socket makeWASocket(...)

I believe that this first query is precisely to validate whether the connection was successful, I believe that WhatsApp may not have released the connection correctly when disconnecting or due to the very short interval between disconnection and connection causing the loss of the response to this validation query.

Another way to solve it could be to try to request this query more than once in case of failure... however, in any case, if it were not answered it would continue to crash the application, that's terrible.

laxeder avatar Jan 21 '24 19:01 laxeder

message.upsert still doesn't work with that push sadly

Kuroosh avatar Jan 22 '24 18:01 Kuroosh

message.upsert still doesn't work with that push sadly

This pull request does not solve the problem in messages.upsert, I just referenced the error presented in some related commits

laxeder avatar Jan 22 '24 21:01 laxeder

news guys?

MarkBone avatar Feb 21 '24 22:02 MarkBone

Was this merged? Or do I need to npm install this specific branch?

yuvalwarsh avatar Apr 17 '24 06:04 yuvalwarsh

Was this merged? Or do I need to npm install this specific branch?

?

yuvalwarsh avatar Jun 13 '24 11:06 yuvalwarsh