Quantcast
Channel: C# Based Open Source SNMP Library for .NET and Mono
Viewing all articles
Browse latest Browse all 576

New Post: "Wrong response sequence" OperationException

$
0
0
Hi,

Got an issue with the use of SharpSnmpLib: I often (~50% of times) got an exception when doing a simple SNMP GET:

Message:
wrong response sequence: expected -1649357291, received -1632514283
StackTrace:
at Lextm.SharpSnmpLib.Messaging.SnmpMessageExtension.GetResponse(ISnmpMessage request, Int32 timeout, IPEndPoint receiver, UserRegistry registry, Socket udpSocket)
at Lextm.SharpSnmpLib.Messaging.SnmpMessageExtension.GetResponse(ISnmpMessage request, Int32 timeout, IPEndPoint receiver, Socket udpSocket)
at Lextm.SharpSnmpLib.Messaging.SnmpMessageExtension.GetResponse(ISnmpMessage request, Int32 timeout, IPEndPoint receiver)
at Lextm.SharpSnmpLib.Messaging.Messenger.Get(VersionCode version, IPEndPoint endpoint, OctetString community, IList`1 variables, Int32 timeout)
at ConsoleApplication1.Program.Main(String[] args) in C:\ConsoleApplication1\Program.cs:line 20
This is my code:
static void Main(string[] args) {
    var endPoint = new IPEndPoint(IPAddress.Parse("192.168.109.10"), 161);
    var variablesGet = new List<Variable> {
        new Variable(new ObjectIdentifier(".1.3.6.1.4.1.27359.12.10.6.1.3.18"))
    };
    while (true) {
        try {
            var result = Messenger.Get(
                    VersionCode.V1,
                    endPoint,
                    new OctetString("public"),
                    variablesGet, 
                    0);
            Console.WriteLine(result[0].Data);
        } catch (Exception ex) {
            Console.WriteLine(ex.Message.ToString());
        }
        Console.ReadLine();
    }
}
This snippet is a simple Console application. What is weird is that when it works for the first time, it will work every time for the same console session. And when an exception is raised for the first time, it won't work for the entire console session.

Here the SNMP GET succeeds, and each one succeeds after I hit Enter:
Image
Here the SNMP GET fails, and each one fails after I hit Enter:
Image

Any idea why the GET fails?

Viewing all articles
Browse latest Browse all 576

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>