Skip to content

Commit 65b3350

Browse files
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.
1 parent 3c5b92c commit 65b3350

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/app/ReadHandler.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ 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+
const ScopedNodeId & peer = mSessionHandle ? mSessionHandle->GetPeer() : ScopedNodeId();
182+
ChipLogProgress(DataManagement, "Subscription id 0x%" PRIx32 " from node " ChipLogFormatScopedNodeId " torn down",
183+
mSubscriptionId, ChipLogValueScopedNodeId(peer));
184+
}
185+
#endif // CHIP_PROGRESS_LOGGING
186+
178187
MoveToState(HandlerState::AwaitingDestruction);
179188
mManagementCallback.OnDone(*this);
180189
}

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
109110
// Disallow creating exchange on an inactive session
110-
ChipLogError(ExchangeManager, "NewContext failed: session inactive");
111+
const ScopedNodeId & peer = session->GetPeer();
112+
ChipLogError(ExchangeManager, "NewContext failed: session %u to " ChipLogFormatScopedNodeId " is inactive",
113+
session->SessionIdForLogging(), ChipLogValueScopedNodeId(peer));
114+
#endif // CHIP_ERROR_LOGGING
115+
111116
return nullptr;
112117
}
113118
return mContextPool.CreateObject(this, mNextExchangeId++, session, isInitiator, delegate);

0 commit comments

Comments
 (0)