Hi Guys,
I have recently upgraded to mono-3.0.3 from 2.6.7 and one thing I have noticed is that the GetResponse method sometime freezes and never returns.
My code look like this:
privatestring GetInternal(string ip, string community, string oid, int timeout) { ISnmpMessage response; string s; try { List<Variable> vList = new List<Variable>(); Variable item = new Variable(new ObjectIdentifier(oid)); vList.Add(item); int random = Utils.GenerateRandomNumber(6); GetRequestMessage message = new GetRequestMessage(random, VersionCode.V2, new OctetString(community), vList); IPAddress ipadr; if (IPAddress.TryParse(ip, out ipadr)) { IPEndPoint endpoint = new IPEndPoint(ipadr, 161); Glog.Add(Glog.Severity.InfoHigh, Utils.GetName(ip), "Sending SNMP get request", "oid: "+ oid + "\n"+ "timeout: "+ timeout); response = message.GetResponse(timeout, endpoint, _udp); Glog.Add(Glog.Severity.InfoHigh, Utils.GetName(ip), "Got SNMP get response back", "oid: "+ oid); } else { Glog.Add(Glog.Severity.Error, Utils.GetName(ip), "Could not parse ip!", "IP was: "+ ip); return""; } //check that we atleast have one request header else return nothingif (response.Pdu().Variables.Count == 0) return""; if (response.Pdu().ErrorStatus.ToInt32() != 0) { Glog.Add(Glog.Severity.Warning, Utils.GetName(ip), "SNMP error returned from server", "ErrorStatus: "+ response.Pdu().ErrorStatus.ToInt32()); return""; } //The response from server. s = response.Pdu().Variables[0].Data.ToString(); } catch (SocketException ex) { Glog.Add(ex, Glog.Severity.Warning, Utils.GetName(ip), "Error connecting to host!", ex.Message); s=""; } catch (Lextm.SharpSnmpLib.Messaging.TimeoutException ex) { Glog.Add(ex, Glog.Severity.Warning, Utils.GetName(ip), "Timeout to host, retuning nothing", ex.Message); s = ""; } catch (OperationException ex) { Glog.Add(ex, Glog.Severity.Warning, Utils.GetName(ip), "Operation Exception, message: "+ ex.Message, ""); Thread.Sleep(10000); //hack, because we get "wrong response sequence: expected 110284, received 110430" over and over. s = ""; } catch (Exception ex) { Glog.Add(ex); s = ""; } Glog.Add(Glog.Severity.InfoHigh, Utils.GetName(ip), "Returning SNMP data from server", "data: "+ s); return s; }
The problem occurs on the line:
response = message.GetResponse(timeout, endpoint, _udp);
As you can see I log (the Glog static class), just before and after and I can see that it happens at this specific line.
The timeout I use is 3000, should it should return after 3 secs.
What happens is that when my thread is not moving forward I have a watchdog that is killing it and starts it over (watchdog timeout is 900sec).
It not like it happens on one particular host eller OID, I find it fairly random, however I do have about 95 threads that is running (on thread requests about 40-50 OIDs per host)
I have tried with v6.0 and v7.5, but it is the same problem.
Does anyone have a good idea what I can do to debug this?
Cheers
Esben