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

some messages gets lost on poor connection #1161

Open
readyblue opened this issue Sep 1, 2023 · 2 comments
Open

some messages gets lost on poor connection #1161

readyblue opened this issue Sep 1, 2023 · 2 comments
Labels
question Further information is requested response needed Waiting for additional information

Comments

@readyblue
Copy link
Contributor

Hi @robinlinden Robin,

I have noticed lately, that on some cases with poor wifi the messages send from aTox does not get delivered.
While TOX implements read receipts, would be possible to implement mechanism that sends message only after the read receipts gets delivered from previous message? And also display this event in the chat log window so that it will be possible to resend the message without read receipts delivered?

As it is better to even send message twice than loose it.

Thanks for aTox in any way.

@robinlinden robinlinden added question Further information is requested response needed Waiting for additional information labels Sep 1, 2023
@robinlinden
Copy link
Collaborator

robinlinden commented Sep 1, 2023

Hi @readyblue!

While TOX implements read receipts, would be possible to implement mechanism that sends message only after the read receipts gets delivered from previous message?

aTox should already be resending all undelivered messages in the correct order, but we don't wait for one message to be acknowledged before sending the next, so I guess in theory a message could get lost a second time, and then we'd end up with out-of-order problems. If you feel like having a look at making a PR for this, it'd be very welcome. :) After speaking to a friend, this shouldn't be able to happen either. Have you had messages delivered out-of-order from aTox to aTox, uTox, Toxic, or qTox?

See:

fun resend(messages: List<Message>) = scope.launch {
for (message in messages) {
val msgs = message.message.chunked(MAX_MESSAGE_LENGTH)
while (msgs.size > 1) {
tox.sendMessage(PublicKey(message.publicKey), msgs.removeFirst(), message.type)
}
messageRepository.setCorrelationId(
message.id,
tox.sendMessage(PublicKey(message.publicKey), msgs.first(), message.type),
)
}
}

friendConnectionStatusHandler = { publicKey, status ->
contactRepository.setConnectionStatus(publicKey, status)
if (status != ConnectionStatus.None) {
scope.launch {
val pending = messageRepository.getPending(publicKey)
if (pending.isNotEmpty()) {
chatManager.resend(pending)
}

And also display this event in the chat log window so that it will be possible to resend the message without read receipts delivered?

aTox already resends all messages that it doesn't get read-receipts for, so if aTox doesn't display "sending" under a message, the Tox client on the other side has sent a read-receipt. Are you sure it's not the other side dropping the messages after receiving them and sending a read-receipt?

See:

fun sendMessage(publicKey: PublicKey, message: String, type: MessageType = MessageType.Normal) =
scope.launch {
if (contactRepository.get(publicKey.string()).first().connectionStatus == ConnectionStatus.None) {
queueMessage(publicKey, message, type)
return@launch
}
val msgs = message.chunked(MAX_MESSAGE_LENGTH)
while (msgs.size > 1) {
tox.sendMessage(publicKey, msgs.removeFirst(), type)
}
messageRepository.add(
Message(
publicKey.string(),
message,
Sender.Sent,
type,
tox.sendMessage(publicKey, msgs.first(), type),
),
)
}

friendReadReceiptHandler = { publicKey, messageId ->
messageRepository.setReceipt(publicKey, messageId, Date().time)
}

val unsent = message.timestamp == 0L
vh.message.text = message.message
vh.timestamp.text = if (!unsent) {
timeFormatter.format(message.timestamp)
} else {
resources.getText(R.string.sending)
}

Thank you for getting in touch! Always nice to hear from people using aTox!

@readyblue
Copy link
Contributor Author

With all due respect, there may be a reason why it might be a good idea to keep message delivery in order, like:
meme_msg_not_delivered_in_order

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested response needed Waiting for additional information
Projects
None yet
Development

No branches or pull requests

2 participants