Когда я пытаюсь сделать запрос SNMP V3, он показывает эту ошибку «Запрос достиг максимальных попыток». когда он достигнет цели. Открытие (param), я искал решение в интернете, но ничего не закончил, я не знаю, что его вызвало и почему это происходит, что-нибудь поможет вам большое спасибо
Я просмотрел переполнение стека и нашел этот вопрос, но без ответа Не удается обнаружить SNMP V3 с использованием SnmpSharpNet
IpAddress ipa = new IpAddress("localhost");
UdpTarget target = new UdpTarget((IPAddress)ipa);
SecureAgentParameters param = new SecureAgentParameters();
if (!target.Discovery(param))
{
Console.WriteLine("Discovery failed. Unable to continue...");
target.Close();
return;
}
// Construct a Protocol Data Unit (PDU)
Pdu pdu = new Pdu();
// Set the request type (default is Get)
pdu.Type = PduType.Get;
// Add variables you wish to query
pdu.VbList.Add("1.3.6.1.2.1.1.1.0");
Oid oidVal1 = new Oid(new int[] { 1, 3, 6, 1, 2, 1, 1, 2, 0 });
pdu.VbList.Add(oidVal1);
Oid oidVal2 = new Oid("1.3.6.1.2.1.1.3.0");
pdu.VbList.Add(oidVal2);
// optional: make sure no authentication or privacy is configured in the
// SecureAgentParameters class (see discovery section above)
param.authPriv(
"priv1",
AuthenticationDigests.MD5, "test1234",
PrivacyProtocols.AES128, "1234test");
// Make a request. Request can throw a number of errors so wrap it in try/catch
SnmpV3Packet result;
try
{
result = (SnmpV3Packet)target.Request(pdu, param);
}
catch (Exception ex)
{
Console.WriteLine("Error: {0}", ex.Message);
result = null;
}
if (result != null)
{
if (result.ScopedPdu.Type == PduType.Report)
{
Console.WriteLine("SNMPv3 report:");
foreach (Vb v in result.ScopedPdu.VbList)
{
Console.WriteLine("{0} -> ({1}) {2}",
v.Oid.ToString(),
SnmpConstants.GetTypeName(v.Value.Type), v.Value.ToString());
}
}
else
{
if (result.ScopedPdu.ErrorStatus == 0)
{
foreach (Vb v in result.ScopedPdu.VbList)
{
Console.WriteLine("{0} -> ({1}) {2}",
v.Oid.ToString(),
SnmpConstants.GetTypeName(v.Value.Type), v.Value.ToString());
}
}
else
{
Console.WriteLine("SNMPError: {0} ({1}): {2}",
SnmpError.ErrorMessage(result.ScopedPdu.ErrorStatus),
result.ScopedPdu.ErrorStatus, result.ScopedPdu.ErrorIndex);
}
}
}
target.Close();