Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added function to send an ack on demand #995

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bmatasar
Copy link

@bmatasar bmatasar commented Sep 27, 2023

In the specs it says:

Either party MAY send an element at any time (e.g., after it has received a certain number of stanzas, or after a certain period of time), even if it has not received an element from the other party. It is RECOMMENDED that initiating entities (usually clients) send an element right before they gracefully close the stream, in order to inform the peer about received stanzas. Otherwise it can happen that stanzas are re-sent (usually by the server) although they were actually received.

I added a simple function to do that.
Usage:
client.streamManagement.sendAck()

@singpolyma
Copy link
Contributor

Should this also automatically call right before disconnect?

@bmatasar
Copy link
Author

bmatasar commented Nov 8, 2023

This is a good question. In XEP-0198 they don't mention such a thing. They have 2 scenarios, one where an ack is sent after every message, the other with an ack sent every 5th message.
In my use case I get seldom a couple of packets and the second scenario might leave some in the air, so I preferred to send an ack after processing a bulk.

Sending an ack before going offline might seem a good idea. Adding a config property to send automatically an ack after every n-th message would be another useful thing.

Please let me know if I can help with any of the 2.

@singpolyma
Copy link
Contributor

It's right in your quote in the OP here:

It is RECOMMENDED that initiating entities (usually clients) send an element right before they gracefully close the stream, in order to inform the peer about received stanzas

otherwise I would only send when asked by the other side, as is done now.

@bmatasar
Copy link
Author

bmatasar commented Nov 8, 2023

I added the sending of the ack before going offline. I hope that is enough.

nicseltzer added a commit to gafftape-industries/xmpp.js that referenced this pull request Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants