Search code examples
c#sharp-snmp

Getting TimeoutException on sending Informs via SharpSNMPLib


I am using SharpSNMPLib on C# to send Informs but always getting a timeoutException. This is apparently caused by the lack of reply as stated on the documentation here :

Messenger.SendInform(0, 
                     VersionCode.V2, 
                     new IPEndPoint(IPAddress.Parse("192.168.1.3"), 162), 
                     new OctetString("public"), 
                     new ObjectIdentifier("1.3.6.1.2.1.1"), 
                     0, 
                     new List<Variable>(), 
                     2000, 
                     null, 
                     null);

The manager should send back a reply to this INFORM message. Otherwise, a TimeoutException occurs.

Does anyone know how to send back a reply in order to avoid this exception?


Solution

  • Answered offline, but paste the answer here for future reference.

    The code base contains an snmptrapd sample, which illustrated how to construct a manager pipeline,

    https://github.com/lextm/sharpsnmplib/blob/master/Samples/CSharp/snmptrapd/Program.cs

    It is such a pipeline that handles incoming TRAP and INFORM messages and replies in a proper way.

    You might further read the checkout steps to see how the test agent and snmptrapd should work together,

    http://docs.sharpsnmp.com/en/latest/samples/command-line-tools.html#checkout

    When an INFORM message is sent from the test agent after the button is clicked, the snmptrapd program will reply to it and log to console.