Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Add keep-alive support for a more persistent connection #21

Merged
merged 27 commits into from
Jan 30, 2022

Conversation

reinier-millo
Copy link
Collaborator

I have rebased master branch into develop, and added support to prevent websocket be closed after 30 seconds. It must solve issue #18

lc-at and others added 18 commits June 9, 2020 15:19
Bumps [websockets](https://github.com/aaugustin/websockets) from 8.1 to 9.1.
- [Release notes](https://github.com/aaugustin/websockets/releases)
- [Changelog](https://github.com/aaugustin/websockets/blob/9.1/docs/changelog.rst)
- [Commits](python-websockets/websockets@8.1...9.1)

---
updated-dependencies:
- dependency-name: websockets
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [websockets](https://github.com/aaugustin/websockets) from 8.1 to 9.1.
- [Release notes](https://github.com/aaugustin/websockets/releases)
- [Changelog](https://github.com/aaugustin/websockets/blob/9.1/docs/changelog.rst)
- [Commits](python-websockets/websockets@8.1...9.1)

---
updated-dependencies:
- dependency-name: websockets
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
…ckets-9.1

Bump websockets from 8.1 to 9.1 in /kyros
…l-5.4

Bump pyyaml from 5.3.1 to 5.4 in /kyros
* Send keep alive message every 10 seconds
* Ignore server timestamp response

Signed-off-by: Reinier Millo <[email protected]>
* After user scanned QR code
* After session restored

Signed-off-by: Reinier Millo <[email protected]>
Merge branch 'feature/prevent-websocket-close' into develop
Signed-off-by: Reinier Millo <[email protected]>
@lc-at lc-at changed the title Develop Add keep-alive support for a more persistent conneciton Jan 15, 2022
@lc-at lc-at requested review from lc-at and rijumone January 15, 2022 17:41
Copy link
Owner

@lc-at lc-at left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a glance, it looks quite good to me. However, you need to make sure that your code is consistent with the whole code base (make sure it complies to PEP8).

I haven't tested the code though, but it looks promising.

kyros/websocket.py Outdated Show resolved Hide resolved
kyros/websocket.py Outdated Show resolved Hide resolved
@lc-at
Copy link
Owner

lc-at commented Jan 15, 2022

@rijumone, can you test and review this?

@lc-at lc-at changed the title Add keep-alive support for a more persistent conneciton Add keep-alive support for a more persistent connection Jan 15, 2022
@lc-at lc-at linked an issue Jan 15, 2022 that may be closed by this pull request
Reinier Millo added 2 commits January 15, 2022 17:36
* Change keepAlive function name to keep_alive
* Add missing space

Signed-off-by: Reinier Millo <[email protected]>
@rijumone
Copy link
Collaborator

@rijumone, can you test and review this?

@p4kl0nc4t, I would love to. However, I am yet to get this library running on my dev environment owing to #19 . Would it be possible to hop on a Zoom call or something to get me up to speed on this? An overall walk-through of the library would also be greatly appreciated.

Reinier Millo added 6 commits January 29, 2022 04:10
* Plain text messages area send to queue
* Binary messages are send to message handler

Signed-off-by: Reinier Millo <[email protected]>
* Dispatch keep alive message after conn received

Signed-off-by: Reinier Millo <[email protected]>
Signed-off-by: Reinier Millo <[email protected]>
* Add callback function
* TODO Identify message types to call handlers

Signed-off-by: Reinier Millo <[email protected]>
* Support to save/load session in JSON file
* User message handle callback to log received messages

Signed-off-by: Reinier Millo <[email protected]>
* Receive text messages from WhatsApp
@reinier-millo reinier-millo merged commit 491e2a6 into lc-at:develop Jan 30, 2022
lc-at pushed a commit that referenced this pull request Nov 2, 2023
Add keep-alive support for a more persistent connection

Websocket was closing after 30 seconds. WhatsApp don't use ping/pong timeout handled by websocket protocol. This timeouts must be disabled, and send custom message every 10 seconds to keep alive the connection. WhatsApp server will respond to the custom message with a plain text message with current server timestamps.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

connection is lost.
3 participants