D
dherberger
Guest
I have a service that listens for SNMP traps using SharpSnmpLib v11.1.0. The service was running fine for some time. I was adding the network switches one at a time to tweak the code. When I got the the 5th switch, the service started to crash. I had my Server Admin give me a Full Dump file. It seems to me that the process of starting it in Async is breaking.
Note: I have not upgrade to SharpSnmpLib v11.2.0 since the github repository states "Visual Studio 2019 and .NET Core SDK (for .NET Core 2.1 and above) is required to compile it on Windows" which I do not have.
The Call Stack shows a break in StartOperationReceiveMessageFrom() but the break-point is in SendToAsync().
Listener Setup
var users = new UserRegisty();
// Private variables set from DB in constructor
users.Add(_SNMPUsername, new DefaultPrivacyProvider(new SHA1AuthenticationProvider(_SNMPPassword)));
_Listener = new Listener { Users = users };
_Listener.AddBinding(new IPEndPoint(IPAddress.Any, 162));
_Listener.MessageReceived += Listener_MessageReceived;
_Listener.StartAsync();
Message Received Method
private static void Listener_MessageReceived(object sender, MessageReceivedEventArgs e)
{
if (e.Message.ToString().Contains("1.3.6.1.6.3.1.1.5.4"))
{
string ipAddress = e.Sender.Address.ToString(),
port = e.Message.Scope.Pdu.Variables[0].Data.ToString();
if (PortScanInProgress(ipAddress, port))
return;
// Perform the scan on the port
TrapReceivedAsync(ipAddress, port);
}
}
Task Method
protected static async Task TrapReceivedAsync(string ip, string port)
{
Do Work...
}
Where is the breakdown occurring?
I have also posted photos on Stackoverflow since I cannot here:
Windows Service for SNMP crashes when message is received
Also, I am using VS 2017 Pro on a Windows 10 machine.
Continue reading...
Note: I have not upgrade to SharpSnmpLib v11.2.0 since the github repository states "Visual Studio 2019 and .NET Core SDK (for .NET Core 2.1 and above) is required to compile it on Windows" which I do not have.
The Call Stack shows a break in StartOperationReceiveMessageFrom() but the break-point is in SendToAsync().
Listener Setup
var users = new UserRegisty();
// Private variables set from DB in constructor
users.Add(_SNMPUsername, new DefaultPrivacyProvider(new SHA1AuthenticationProvider(_SNMPPassword)));
_Listener = new Listener { Users = users };
_Listener.AddBinding(new IPEndPoint(IPAddress.Any, 162));
_Listener.MessageReceived += Listener_MessageReceived;
_Listener.StartAsync();
Message Received Method
private static void Listener_MessageReceived(object sender, MessageReceivedEventArgs e)
{
if (e.Message.ToString().Contains("1.3.6.1.6.3.1.1.5.4"))
{
string ipAddress = e.Sender.Address.ToString(),
port = e.Message.Scope.Pdu.Variables[0].Data.ToString();
if (PortScanInProgress(ipAddress, port))
return;
// Perform the scan on the port
TrapReceivedAsync(ipAddress, port);
}
}
Task Method
protected static async Task TrapReceivedAsync(string ip, string port)
{
Do Work...
}
Where is the breakdown occurring?
I have also posted photos on Stackoverflow since I cannot here:
Windows Service for SNMP crashes when message is received
Also, I am using VS 2017 Pro on a Windows 10 machine.
Continue reading...