tulir / whatsmeow

Go library for the WhatsApp web multidevice API
https://go.mau.fi/whatsmeow
Mozilla Public License 2.0
2.29k stars 427 forks source link

Add ConnectWithTimeout method to support having a timeout when connecting. #596

Open ALiwoto opened 6 months ago

ALiwoto commented 6 months ago

This pull request adds a new method called ConnectWithTimeout to support having a timeout set when connecting to whatsapp. This context.Conext is later on passed to fs and is used when connecting (previously, we have been using context.Backgound() for the fs). Can also use context.Background() if we do not want any timeout.

blaggacao commented 4 months ago

Can you say a word or two about the motivation and concrete failure mode which triggered this?

I'm seeing timeout related issues and wonder if this was indirectly made to address a functionally equal failure mode as the one I observe.

I'm not currently [using a timeout](https://github.com/blaggacao/whatsmeow-native/blob/0150511fcce1efa500ece8065e9a3e9555e2e7c5/main.go#L106) on the service, but when connecting to the whatsmeow service socket, I use a timeout of 15 seconds within the application. This seems to cause cascading issues some times.
huzairuje commented 3 weeks ago

@blaggacao i think this PR should be implemented, i have an issue sometimes the server got internet issue and we don't have any problem regarding how to connect using timeout or context cancelled.