Skip to content

Commit d9cbc1f

Browse files
Improve server logging on subscription failures. (#33372)
* Improve server logging on subscription failures. 1) When logging "session inactive", log which session it is. 2) When a subscription ReadHandler closes, log the relevant subscription ID and peer node. * Address review comment.
1 parent d1d0d2b commit d9cbc1f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/app/ReadHandler.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ void ReadHandler::Close(CloseOptions options)
175175
}
176176
}
177177
#endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
178+
179+
#if CHIP_PROGRESS_LOGGING
180+
if (IsType(InteractionType::Subscribe))
181+
{
182+
const ScopedNodeId & peer = mSessionHandle ? mSessionHandle->GetPeer() : ScopedNodeId();
183+
ChipLogProgress(DataManagement, "Subscription id 0x%" PRIx32 " from node " ChipLogFormatScopedNodeId " torn down",
184+
mSubscriptionId, ChipLogValueScopedNodeId(peer));
185+
}
186+
#endif // CHIP_PROGRESS_LOGGING
187+
178188
MoveToState(HandlerState::AwaitingDestruction);
179189
mManagementCallback.OnDone(*this);
180190
}

src/messaging/ExchangeMgr.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,13 @@ ExchangeContext * ExchangeManager::NewContext(const SessionHandle & session, Exc
106106
{
107107
if (!session->IsActiveSession())
108108
{
109+
#if CHIP_ERROR_LOGGING
110+
const ScopedNodeId & peer = session->GetPeer();
111+
ChipLogError(ExchangeManager, "NewContext failed: session %u to " ChipLogFormatScopedNodeId " is inactive",
112+
session->SessionIdForLogging(), ChipLogValueScopedNodeId(peer));
113+
#endif // CHIP_ERROR_LOGGING
114+
109115
// Disallow creating exchange on an inactive session
110-
ChipLogError(ExchangeManager, "NewContext failed: session inactive");
111116
return nullptr;
112117
}
113118
return mContextPool.CreateObject(this, mNextExchangeId++, session, isInitiator, delegate);

0 commit comments

Comments
 (0)