Skip to content

Commit

Permalink
Exchange optimizations (#1168)
Browse files Browse the repository at this point in the history
* Do not create exchange for just a standalone ack

... because most likely the standalone ack is from a former unacknowledged message

* Do not send failure for RetryExceeded error

When we send a response to the peer and do not receive the ack we throw internally an RetransmissionLimitReachedError. In this case we do not need to send another status (most likely we also can not because last message is still unacknowledged) and we did anything we could, so ignore error. Additionally, irrelevant for us because we are just the server,

* Adjust some loglevels
  • Loading branch information
Apollon77 authored Sep 7, 2024
1 parent 67d747f commit 13ba5e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/matter.js/src/protocol/ExchangeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ export class ExchangeManager<ContextT extends SessionContext> {
const protocolHandler = this.protocols.get(message.payloadHeader.protocolId);

if (protocolHandler !== undefined && message.payloadHeader.isInitiatorMessage && !isDuplicate) {
if (
message.payloadHeader.messageType == MessageType.StandaloneAck &&
!message.payloadHeader.requiresAck
) {
logger.debug(
`Ignoring unsolicited standalone ack message ${messageId} for protocol ${message.payloadHeader.protocolId} and exchange id ${message.payloadHeader.exchangeId}.`,
);
return;
}

const exchange = MessageExchange.fromInitialMessage(
await this.channelManager.getOrCreateChannel(channel, session),
message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,12 @@ export class InteractionServerMessenger extends InteractionMessenger<MatterDevic
if (error instanceof StatusResponseError) {
logger.info(`Sending status response ${error.code} for interaction error: ${error.message}`);
errorStatusCode = error.code;
} else if (error instanceof RetransmissionLimitReachedError) {
logger.info(error);
} else {
logger.error(error);
logger.warn(error);
}
if (!isGroupSession) {
if (!isGroupSession && !(error instanceof RetransmissionLimitReachedError)) {
await this.sendStatus(errorStatusCode);
}
} finally {
Expand Down

0 comments on commit 13ba5e2

Please sign in to comment.