Skip to content

Commit

Permalink
Add logging around heartbeats
Browse files Browse the repository at this point in the history
  • Loading branch information
PewPewRaj committed Dec 5, 2023
1 parent 0419d6b commit f7502fc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/src/client/impl/channel_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class _ChannelImpl implements Channel {

void writeHeartbeat() {
if (_channelClosed != null || _client._socket == null) {
connectionLogger.warning("writeHeartbeat skipped for vhost=${_client.settings.virtualHost}, host=${_client.settings.host}: _channelClosed=$_channelClosed _client._socket=${_client._socket}");
return; // no-op
}

Expand All @@ -69,7 +70,9 @@ class _ChannelImpl implements Channel {
_frameWriter
..writeHeartbeat()
..pipe(_client._socket!);
} catch (_) {
connectionLogger.info("writeHeartbeat transmitted for vhost=${_client.settings.virtualHost}, host=${_client.settings.host}");
} catch (e, st) {
connectionLogger.warning("writeHeartbeat failed for vhost=${_client.settings.virtualHost}, host=${_client.settings.host}: $e", null, st);
// An exception will be raised if we attempt to send a hearbeat
// immediately after the connection to the server is lost. We can safely
// ignore this error; clients will be notified of the lost connection via
Expand Down

0 comments on commit f7502fc

Please sign in to comment.