diff --git a/.gitignore b/.gitignore
index 7d6bdbf60..37c55e1b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,4 @@ project.lock.json
# Build outputs
build/target/
+/.vs
diff --git a/src/Renci.SshNet/Abstractions/DiagnosticAbstraction.cs b/src/Renci.SshNet/Abstractions/DiagnosticAbstraction.cs
index 6fc1308ee..db81ed217 100644
--- a/src/Renci.SshNet/Abstractions/DiagnosticAbstraction.cs
+++ b/src/Renci.SshNet/Abstractions/DiagnosticAbstraction.cs
@@ -1,22 +1,30 @@
using System.Diagnostics;
-#if FEATURE_DIAGNOSTICS_TRACESOURCE
-using System.Threading;
-#endif // FEATURE_DIAGNOSTICS_TRACESOURCE
namespace Renci.SshNet.Abstractions
{
+ ///
+ /// Diagnostics for Renci library
+ ///
internal static class DiagnosticAbstraction
{
#if FEATURE_DIAGNOSTICS_TRACESOURCE
private static readonly SourceSwitch SourceSwitch = new SourceSwitch("SshNetSwitch");
+ ///
+ /// Whether the specified event type is enabled for tracing or not
+ ///
+ /// The trace event type
+ /// true if enabled for tracing, false otherwise
public static bool IsEnabled(TraceEventType traceEventType)
{
return SourceSwitch.ShouldTrace(traceEventType);
}
- private static readonly TraceSource Loggging =
+ ///
+ /// The trace source for Renci
+ ///
+ public static readonly TraceSource Logging =
#if DEBUG
new TraceSource("SshNet.Logging", SourceLevels.All);
#else
@@ -24,11 +32,17 @@ public static bool IsEnabled(TraceEventType traceEventType)
#endif // DEBUG
#endif // FEATURE_DIAGNOSTICS_TRACESOURCE
+ ///
+ /// Log the provided text
+ ///
+ /// The text string to log
+ /// The trace event type
+ /// A numeric identifier for the event.
[Conditional("DEBUG")]
- public static void Log(string text)
+ public static void Log(string text, TraceEventType eventType, TraceEventId id)
{
#if FEATURE_DIAGNOSTICS_TRACESOURCE
- Loggging.TraceEvent(TraceEventType.Verbose, Thread.CurrentThread.ManagedThreadId, text);
+ Logging.TraceEvent(eventType, (int)id, text);
#endif // FEATURE_DIAGNOSTICS_TRACESOURCE
}
}
diff --git a/src/Renci.SshNet/BaseClient.cs b/src/Renci.SshNet/BaseClient.cs
index 5b0e01c90..6615c7641 100644
--- a/src/Renci.SshNet/BaseClient.cs
+++ b/src/Renci.SshNet/BaseClient.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.Net.Sockets;
using System.Threading;
using Renci.SshNet.Abstractions;
@@ -245,7 +246,7 @@ public void Connect()
/// The method was called after the client was disposed.
public void Disconnect()
{
- DiagnosticAbstraction.Log("Disconnecting client.");
+ DiagnosticAbstraction.Log("Disconnecting client.", TraceEventType.Verbose, TraceEventId.DisconnectingClient);
CheckDisposed();
@@ -336,7 +337,7 @@ private void Session_HostKeyReceived(object sender, HostKeyEventArgs e)
///
public void Dispose()
{
- DiagnosticAbstraction.Log("Disposing client.");
+ DiagnosticAbstraction.Log("Disposing client.", TraceEventType.Verbose, TraceEventId.DisposingClient);
Dispose(true);
GC.SuppressFinalize(this);
diff --git a/src/Renci.SshNet/Channels/Channel.cs b/src/Renci.SshNet/Channels/Channel.cs
index a6311a981..fbbd4cac0 100644
--- a/src/Renci.SshNet/Channels/Channel.cs
+++ b/src/Renci.SshNet/Channels/Channel.cs
@@ -1,11 +1,12 @@
using System;
+using System.Diagnostics;
+using System.Globalization;
using System.Net.Sockets;
using System.Threading;
+using Renci.SshNet.Abstractions;
using Renci.SshNet.Common;
using Renci.SshNet.Messages;
using Renci.SshNet.Messages.Connection;
-using System.Globalization;
-using Renci.SshNet.Abstractions;
namespace Renci.SshNet.Channels
{
@@ -551,7 +552,7 @@ protected virtual void Close()
var closeWaitResult = _session.TryWait(_channelClosedWaitHandle, ConnectionInfo.ChannelCloseTimeout);
if (closeWaitResult != WaitResult.Success)
{
- DiagnosticAbstraction.Log(string.Format("Wait for channel close not successful: {0:G}.", closeWaitResult));
+ DiagnosticAbstraction.Log(string.Format("Wait for channel close not successful: {0:G}.", closeWaitResult), TraceEventType.Warning, TraceEventId.UnsuccessfulChannelCloseWait);
}
}
}
diff --git a/src/Renci.SshNet/Channels/ChannelDirectTcpip.cs b/src/Renci.SshNet/Channels/ChannelDirectTcpip.cs
index b6ba7a0ba..5dd391770 100644
--- a/src/Renci.SshNet/Channels/ChannelDirectTcpip.cs
+++ b/src/Renci.SshNet/Channels/ChannelDirectTcpip.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Threading;
@@ -138,8 +139,7 @@ private void ShutdownSocket(SocketShutdown how)
}
catch (SocketException ex)
{
- // TODO: log as warning
- DiagnosticAbstraction.Log("Failure shutting down socket: " + ex);
+ DiagnosticAbstraction.Log("Failure shutting down socket: " + ex, TraceEventType.Warning, TraceEventId.SocketShutdownFailure);
}
}
}
diff --git a/src/Renci.SshNet/Channels/ChannelForwardedTcpip.cs b/src/Renci.SshNet/Channels/ChannelForwardedTcpip.cs
index 7d731b9e5..4fbafde69 100644
--- a/src/Renci.SshNet/Channels/ChannelForwardedTcpip.cs
+++ b/src/Renci.SshNet/Channels/ChannelForwardedTcpip.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using Renci.SshNet.Abstractions;
@@ -134,8 +135,7 @@ private void ShutdownSocket(SocketShutdown how)
}
catch (SocketException ex)
{
- // TODO: log as warning
- DiagnosticAbstraction.Log("Failure shutting down socket: " + ex);
+ DiagnosticAbstraction.Log("Failure shutting down socket: " + ex, TraceEventType.Warning, TraceEventId.SocketShutdownFailure);
}
}
}
diff --git a/src/Renci.SshNet/Connection/ConnectorBase.cs b/src/Renci.SshNet/Connection/ConnectorBase.cs
index 6e9bed7af..7dfc94b9f 100644
--- a/src/Renci.SshNet/Connection/ConnectorBase.cs
+++ b/src/Renci.SshNet/Connection/ConnectorBase.cs
@@ -1,9 +1,10 @@
-using Renci.SshNet.Abstractions;
-using Renci.SshNet.Common;
-using Renci.SshNet.Messages.Transport;
-using System;
+using System;
+using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
+using Renci.SshNet.Abstractions;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Transport;
namespace Renci.SshNet.Connection
{
@@ -34,7 +35,7 @@ protected Socket SocketConnect(string host, int port, TimeSpan timeout)
var ipAddress = DnsAbstraction.GetHostAddresses(host)[0];
var ep = new IPEndPoint(ipAddress, port);
- DiagnosticAbstraction.Log(string.Format("Initiating connection to '{0}:{1}'.", host, port));
+ DiagnosticAbstraction.Log(string.Format("Initiating connection to '{0}:{1}'.", host, port), TraceEventType.Verbose, TraceEventId.SocketConnection);
var socket = SocketFactory.Create(ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
diff --git a/src/Renci.SshNet/ForwardedPortDynamic.NET.cs b/src/Renci.SshNet/ForwardedPortDynamic.NET.cs
index 36a804558..e4e873afc 100644
--- a/src/Renci.SshNet/ForwardedPortDynamic.NET.cs
+++ b/src/Renci.SshNet/ForwardedPortDynamic.NET.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Net;
@@ -266,8 +267,7 @@ partial void InternalStop(TimeSpan timeout)
_pendingChannelCountdown.Signal();
if (!_pendingChannelCountdown.Wait(timeout))
{
- // TODO: log as warning
- DiagnosticAbstraction.Log("Timeout waiting for pending channels in dynamic forwarded port to close.");
+ DiagnosticAbstraction.Log("Timeout waiting for pending channels in dynamic forwarded port to close.", TraceEventType.Warning, TraceEventId.PendingChannelsCloseTimeout);
}
}
diff --git a/src/Renci.SshNet/ForwardedPortLocal.NET.cs b/src/Renci.SshNet/ForwardedPortLocal.NET.cs
index ba01ddbd3..f1e0e0eb9 100644
--- a/src/Renci.SshNet/ForwardedPortLocal.NET.cs
+++ b/src/Renci.SshNet/ForwardedPortLocal.NET.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.Net.Sockets;
using System.Net;
using System.Threading;
@@ -216,8 +217,7 @@ partial void InternalStop(TimeSpan timeout)
_pendingChannelCountdown.Signal();
if (!_pendingChannelCountdown.Wait(timeout))
{
- // TODO: log as warning
- DiagnosticAbstraction.Log("Timeout waiting for pending channels in local forwarded port to close.");
+ DiagnosticAbstraction.Log("Timeout waiting for pending channels in local forwarded port to close.", TraceEventType.Warning, TraceEventId.PendingChannelsCloseTimeout);
}
}
diff --git a/src/Renci.SshNet/ForwardedPortRemote.cs b/src/Renci.SshNet/ForwardedPortRemote.cs
index b2ed15fe4..4e5dfc53b 100644
--- a/src/Renci.SshNet/ForwardedPortRemote.cs
+++ b/src/Renci.SshNet/ForwardedPortRemote.cs
@@ -1,10 +1,11 @@
using System;
-using System.Threading;
-using Renci.SshNet.Messages.Connection;
-using Renci.SshNet.Common;
+using System.Diagnostics;
using System.Globalization;
using System.Net;
+using System.Threading;
using Renci.SshNet.Abstractions;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Connection;
namespace Renci.SshNet
{
@@ -204,8 +205,7 @@ protected override void StopPort(TimeSpan timeout)
if (!_pendingChannelCountdown.Wait(timeout))
{
- // TODO: log as warning
- DiagnosticAbstraction.Log("Timeout waiting for pending channels in remote forwarded port to close.");
+ DiagnosticAbstraction.Log("Timeout waiting for pending channels in remote forwarded port to close.", TraceEventType.Warning, TraceEventId.PendingChannelsCloseTimeout);
}
_status = ForwardedPortStatus.Stopped;
diff --git a/src/Renci.SshNet/Messages/Transport/IgnoreMessage.cs b/src/Renci.SshNet/Messages/Transport/IgnoreMessage.cs
index 580cd3b21..c4908dea5 100644
--- a/src/Renci.SshNet/Messages/Transport/IgnoreMessage.cs
+++ b/src/Renci.SshNet/Messages/Transport/IgnoreMessage.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.Globalization;
using Renci.SshNet.Abstractions;
using Renci.SshNet.Common;
@@ -68,7 +69,7 @@ protected override void LoadData()
if (dataLength > (DataStream.Length - DataStream.Position))
{
- DiagnosticAbstraction.Log("SSH_MSG_IGNORE: Length exceeds data bytes, data ignored.");
+ DiagnosticAbstraction.Log("SSH_MSG_IGNORE: Length exceeds data bytes, data ignored.", TraceEventType.Warning, TraceEventId.ExcessData);
Data = Array.Empty;
}
else
diff --git a/src/Renci.SshNet/Security/KeyExchange.cs b/src/Renci.SshNet/Security/KeyExchange.cs
index a13c272a6..0525e8c9b 100644
--- a/src/Renci.SshNet/Security/KeyExchange.cs
+++ b/src/Renci.SshNet/Security/KeyExchange.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Security.Cryptography;
using Renci.SshNet.Abstractions;
@@ -191,7 +192,9 @@ public Cipher CreateServerCipher()
Session.ToHex(Session.SessionId),
Session.ConnectionInfo.CurrentServerEncryption,
Session.ToHex(serverKey),
- Session.ToHex(serverVector)));
+ Session.ToHex(serverVector)),
+ TraceEventType.Verbose,
+ TraceEventId.ServerCipherCreation);
// Create server cipher
return _serverCipherInfo.Cipher(serverKey, serverVector);
diff --git a/src/Renci.SshNet/ServiceFactory.cs b/src/Renci.SshNet/ServiceFactory.cs
index f04e6116d..c744919b9 100644
--- a/src/Renci.SshNet/ServiceFactory.cs
+++ b/src/Renci.SshNet/ServiceFactory.cs
@@ -1,14 +1,15 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
+using System.Net.Sockets;
using System.Text;
+using Renci.SshNet.Abstractions;
using Renci.SshNet.Common;
+using Renci.SshNet.Connection;
using Renci.SshNet.Messages.Transport;
using Renci.SshNet.Security;
using Renci.SshNet.Sftp;
-using Renci.SshNet.Abstractions;
-using Renci.SshNet.Connection;
-using System.Net.Sockets;
namespace Renci.SshNet
{
@@ -139,7 +140,7 @@ public ISftpFileReader CreateSftpFileReader(string fileName, ISftpSession sftpSe
fileSize = null;
maxPendingReads = defaultMaxPendingReads;
- DiagnosticAbstraction.Log(string.Format("Failed to obtain size of file. Allowing maximum {0} pending reads: {1}", maxPendingReads, ex));
+ DiagnosticAbstraction.Log(string.Format("Failed to obtain size of file. Allowing maximum {0} pending reads: {1}", maxPendingReads, ex), TraceEventType.Warning, TraceEventId.FileSizeFetchFailure);
}
return sftpSession.CreateFileReader(handle, sftpSession, chunkSize, maxPendingReads, fileSize);
diff --git a/src/Renci.SshNet/Session.cs b/src/Renci.SshNet/Session.cs
index 0748b8dac..3cdeed5d6 100644
--- a/src/Renci.SshNet/Session.cs
+++ b/src/Renci.SshNet/Session.cs
@@ -1,8 +1,14 @@
using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Globalization;
+using System.Linq;
+using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
+using Renci.SshNet.Abstractions;
using Renci.SshNet.Channels;
using Renci.SshNet.Common;
using Renci.SshNet.Compression;
@@ -12,9 +18,6 @@
using Renci.SshNet.Messages.Connection;
using Renci.SshNet.Messages.Transport;
using Renci.SshNet.Security;
-using System.Globalization;
-using System.Linq;
-using Renci.SshNet.Abstractions;
using Renci.SshNet.Security.Cryptography;
namespace Renci.SshNet
@@ -594,7 +597,7 @@ public void Connect()
ServerVersion = ConnectionInfo.ServerVersion = serverIdentification.ToString();
ConnectionInfo.ClientVersion = ClientVersion;
- DiagnosticAbstraction.Log(string.Format("Server version '{0}' on '{1}'.", serverIdentification.ProtocolVersion, serverIdentification.SoftwareVersion));
+ DiagnosticAbstraction.Log(string.Format("Server version '{0}' on '{1}'.", serverIdentification.ProtocolVersion, serverIdentification.SoftwareVersion), TraceEventType.Verbose, TraceEventId.ServerVersion);
if (!(serverIdentification.ProtocolVersion.Equals("2.0") || serverIdentification.ProtocolVersion.Equals("1.99")))
{
@@ -678,7 +681,7 @@ public void Connect()
///
public void Disconnect()
{
- DiagnosticAbstraction.Log(string.Format("[{0}] Disconnecting session.", ToHex(SessionId)));
+ DiagnosticAbstraction.Log(string.Format("[{0}] Disconnecting session.", ToHex(SessionId)), TraceEventType.Verbose, TraceEventId.DisconnectingSession);
// send SSH_MSG_DISCONNECT message, clear socket read buffer and dispose it
Disconnect(DisconnectReason.ByApplication, "Connection terminated by the client.");
@@ -900,7 +903,7 @@ internal void SendMessage(Message message)
WaitOnHandle(_keyExchangeCompletedWaitHandle);
}
- DiagnosticAbstraction.Log(string.Format("[{0}] Sending message '{1}' to server: '{2}'.", ToHex(SessionId), message.GetType().Name, message));
+ DiagnosticAbstraction.Log(string.Format("[{0}] Sending message '{1}' to server: '{2}'.", ToHex(SessionId), message.GetType().Name, message), TraceEventType.Verbose, TraceEventId.SendingMessage);
var paddingMultiplier = _clientCipher == null ? (byte) 8 : Math.Max((byte) 8, _serverCipher.MinimumSize);
var packetData = message.GetPacket(paddingMultiplier, _clientCompression);
@@ -1004,12 +1007,12 @@ private bool TrySendMessage(Message message)
}
catch (SshException ex)
{
- DiagnosticAbstraction.Log(string.Format("Failure sending message '{0}' to server: '{1}' => {2}", message.GetType().Name, message, ex));
+ DiagnosticAbstraction.Log(string.Format("Failure sending message '{0}' to server: '{1}' => {2}", message.GetType().Name, message, ex), TraceEventType.Warning, TraceEventId.FailureSendingMessage);
return false;
}
catch (SocketException ex)
{
- DiagnosticAbstraction.Log(string.Format("Failure sending message '{0}' to server: '{1}' => {2}", message.GetType().Name, message, ex));
+ DiagnosticAbstraction.Log(string.Format("Failure sending message '{0}' to server: '{1}' => {2}", message.GetType().Name, message, ex), TraceEventType.Warning, TraceEventId.FailureSendingMessage);
return false;
}
}
@@ -1160,7 +1163,7 @@ private void TrySendDisconnect(DisconnectReason reasonCode, string message)
/// message.
internal void OnDisconnectReceived(DisconnectMessage message)
{
- DiagnosticAbstraction.Log(string.Format("[{0}] Disconnect received: {1} {2}.", ToHex(SessionId), message.ReasonCode, message.Description));
+ DiagnosticAbstraction.Log(string.Format("[{0}] Disconnect received: {1} {2}.", ToHex(SessionId), message.ReasonCode, message.Description), TraceEventType.Verbose, TraceEventId.DisconnectReceived);
// transition to disconnecting state to avoid throwing exceptions while cleaning up, and to
// ensure any exceptions that are raised do not overwrite the SshConnectionException that we
@@ -1627,7 +1630,7 @@ private Message LoadMessage(byte[] data, int offset, int count)
var message = _sshMessageFactory.Create(messageType);
message.Load(data, offset + 1, count - 1);
- DiagnosticAbstraction.Log(string.Format("[{0}] Received message '{1}' from server: '{2}'.", ToHex(SessionId), message.GetType().Name, message));
+ DiagnosticAbstraction.Log(string.Format("[{0}] Received message '{1}' from server: '{2}'.", ToHex(SessionId), message.GetType().Name, message), TraceEventType.Verbose, TraceEventId.MessageReceived);
return message;
}
@@ -1762,7 +1765,7 @@ private void SocketDisconnectAndDispose()
{
try
{
- DiagnosticAbstraction.Log(string.Format("[{0}] Shutting down socket.", ToHex(SessionId)));
+ DiagnosticAbstraction.Log(string.Format("[{0}] Shutting down socket.", ToHex(SessionId)), TraceEventType.Verbose, TraceEventId.ShuttingDownSocket);
// Interrupt any pending reads; should be done outside of socket read lock as we
// actually want shutdown the socket to make sure blocking reads are interrupted.
@@ -1774,14 +1777,13 @@ private void SocketDisconnectAndDispose()
}
catch (SocketException ex)
{
- // TODO: log as warning
- DiagnosticAbstraction.Log("Failure shutting down socket: " + ex);
+ DiagnosticAbstraction.Log("Failure shutting down socket: " + ex, TraceEventType.Warning, TraceEventId.SocketShutdownFailure);
}
}
- DiagnosticAbstraction.Log(string.Format("[{0}] Disposing socket.", ToHex(SessionId)));
+ DiagnosticAbstraction.Log(string.Format("[{0}] Disposing socket.", ToHex(SessionId)), TraceEventType.Verbose, TraceEventId.DisposingSocket);
_socket.Dispose();
- DiagnosticAbstraction.Log(string.Format("[{0}] Disposed socket.", ToHex(SessionId)));
+ DiagnosticAbstraction.Log(string.Format("[{0}] Disposed socket.", ToHex(SessionId)), TraceEventType.Verbose, TraceEventId.DisposedSocket);
_socket = null;
}
}
@@ -1902,7 +1904,7 @@ private void RaiseError(Exception exp)
{
var connectionException = exp as SshConnectionException;
- DiagnosticAbstraction.Log(string.Format("[{0}] Raised exception: {1}", ToHex(SessionId), exp));
+ DiagnosticAbstraction.Log(string.Format("[{0}] Raised exception: {1}", ToHex(SessionId), exp), TraceEventType.Error, TraceEventId.RaisedException);
if (_isDisconnecting)
{
@@ -1928,7 +1930,7 @@ private void RaiseError(Exception exp)
if (connectionException != null)
{
- DiagnosticAbstraction.Log(string.Format("[{0}] Disconnecting after exception: {1}", ToHex(SessionId), exp));
+ DiagnosticAbstraction.Log(string.Format("[{0}] Disconnecting after exception: {1}", ToHex(SessionId), exp), TraceEventType.Warning, TraceEventId.DisconnectingAfterException);
Disconnect(connectionException.DisconnectReason, exp.ToString());
}
}
@@ -1984,7 +1986,7 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
- DiagnosticAbstraction.Log(string.Format("[{0}] Disposing session.", ToHex(SessionId)));
+ DiagnosticAbstraction.Log(string.Format("[{0}] Disposing session.", ToHex(SessionId)), TraceEventType.Verbose, TraceEventId.DisposingSession);
Disconnect();
diff --git a/src/Renci.SshNet/Sftp/SftpFileReader.cs b/src/Renci.SshNet/Sftp/SftpFileReader.cs
index 3aed4f535..dc3d28012 100644
--- a/src/Renci.SshNet/Sftp/SftpFileReader.cs
+++ b/src/Renci.SshNet/Sftp/SftpFileReader.cs
@@ -2,6 +2,7 @@
using Renci.SshNet.Common;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Globalization;
using System.Threading;
@@ -246,7 +247,7 @@ protected void Dispose(bool disposing)
}
catch (Exception ex)
{
- DiagnosticAbstraction.Log("Failure closing handle: " + ex);
+ DiagnosticAbstraction.Log("Failure closing handle: " + ex, TraceEventType.Warning, TraceEventId.FailureClosingHandle);
}
}
}
diff --git a/src/Renci.SshNet/SubsystemSession.cs b/src/Renci.SshNet/SubsystemSession.cs
index 943a2db9e..64184b685 100644
--- a/src/Renci.SshNet/SubsystemSession.cs
+++ b/src/Renci.SshNet/SubsystemSession.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.Globalization;
using System.Threading;
using Renci.SshNet.Abstractions;
@@ -180,7 +181,7 @@ protected void RaiseError(Exception error)
{
_exception = error;
- DiagnosticAbstraction.Log("Raised exception: " + error);
+ DiagnosticAbstraction.Log("Raised exception: " + error, TraceEventType.Error, TraceEventId.RaisedException);
var errorOccuredWaitHandle = _errorOccuredWaitHandle;
if (errorOccuredWaitHandle != null)
diff --git a/src/Renci.SshNet/TraceEventId.cs b/src/Renci.SshNet/TraceEventId.cs
new file mode 100644
index 000000000..de409b218
--- /dev/null
+++ b/src/Renci.SshNet/TraceEventId.cs
@@ -0,0 +1,120 @@
+///
+/// Trace event identifiers enumeration
+///
+public enum TraceEventId
+{
+ ///
+ /// Failure closing handle event identifier
+ ///
+ FailureClosingHandle = 0,
+
+ ///
+ /// Disconnecting client event identifier
+ ///
+ DisconnectingClient = 1,
+
+ ///
+ /// Disposing client event identifier
+ ///
+ DisposingClient = 2,
+
+ ///
+ /// Unsuccessful channel close wait event identifier
+ ///
+ UnsuccessfulChannelCloseWait = 3,
+
+ ///
+ /// Socket shutdown failure event identifier
+ ///
+ SocketShutdownFailure = 4,
+
+ ///
+ /// Pending channels close timeout event identifier
+ ///
+ PendingChannelsCloseTimeout = 5,
+
+ ///
+ /// Excess data event identifier
+ ///
+ ExcessData = 6,
+
+ ///
+ /// Server cipher creation event identifier
+ ///
+ ServerCipherCreation = 7,
+
+ ///
+ /// File size fetch failure event identifier
+ ///
+ FileSizeFetchFailure = 8,
+
+ ///
+ /// Server version event identifier
+ ///
+ ServerVersion = 9,
+
+ ///
+ /// Disconnecting session event identifier
+ ///
+ DisconnectingSession = 10,
+
+ ///
+ /// Sending message event identifier
+ ///
+ SendingMessage = 11,
+
+ ///
+ /// Failure sending message event identifier
+ ///
+ FailureSendingMessage = 12,
+
+ ///
+ /// Disconnect received event identifier
+ ///
+ DisconnectReceived = 13,
+
+ ///
+ /// Message received event identifier
+ ///
+ MessageReceived = 14,
+
+ ///
+ /// Initiating connection event identifier
+ ///
+ InitiatingConnection = 15,
+
+ ///
+ /// Shutting down socket event identifier
+ ///
+ ShuttingDownSocket = 16,
+
+ ///
+ /// Disposing socket event identifier
+ ///
+ DisposingSocket = 17,
+
+ ///
+ /// Disposed socket event identifier
+ ///
+ DisposedSocket = 18,
+
+ ///
+ /// Raised exception event identifier
+ ///
+ RaisedException = 19,
+
+ ///
+ /// Disconnecting after exception event identifier
+ ///
+ DisconnectingAfterException = 20,
+
+ ///
+ /// Disposing session event identifier
+ ///
+ DisposingSession = 21,
+
+ ///
+ /// Socket connection
+ ///
+ SocketConnection = 22,
+}
\ No newline at end of file