1

I am beginner in C# and I am trying to create a tool to read snmp OID for some of my devices. In general the system is working fine at the exception of when I cannot reach the IP address or when the IP Address is not using the same OID.

What I would like to achieve is : In case the device is not reachable : skip to the next one . In case the device has not the right OID : skip to the next one.

Currently when it happens I have an error like this one : Error SnmpSharpNet.SnmpNetworkException: 'Network error: connection reset by peer.'

Caused by SnmpV1Packet result = (SnmpV1Packet)target.Request(pdu, param);

Sample of my code

//Start
UdpTarget target = new UdpTarget((IPAddress)agent, 161, 2000, 1);               
Pdu pdu = new Pdu(PduType.Get);
pdu.VbList.Add(".1.3.6.1.4.1.1552.21.3.1.1.5.1.0");
pdu.VbList.Add(".1.3.6.1.4.1.1552.21.3.1.1.5.2.0");
pdu.VbList.Add(".1.3.6.1.4.1.1552.21.3.1.1.5.7.0");
pdu.VbList.Add(".1.3.6.1.4.1.1552.21.3.1.1.5.8.0");
// Make SNMP request
SnmpV1Packet result = (SnmpV1Packet)target.Request(pdu, param);

// If result is null then agent didn't reply or we couldn't parse the reply.
if (result != null)
{

if (result.Pdu.ErrorStatus != 0)
{
// agent reported an error with the request
MessageBox.Show("Error");
 }

Thank you for your help

Yohann
  • 11
  • 2

1 Answers1

1

I have faced the same issue and the solution was to install SNMP Service on your windows and it should start working fine

this link should help you https://support.microsoft.com/en-us/help/324263/how-to-configure-the-simple-network-management-protocol-snmp-service-i

Saif
  • 75
  • 1
  • 7