【问题标题】:SNMPsharpnet SnmpNetworkException: 'Network error: connection reset by peer.'SNMPsharpnet SnmpNetworkException:“网络错误:对等方重置连接。”
【发布时间】:2019-02-14 15:52:31
【问题描述】:

我是 C# 的初学者,我正在尝试创建一个工具来读取我的某些设备的 snmp OID。 一般来说,系统工作正常,除了当我无法到达 IP 地址或 IP 地址未使用相同的 OID 时。

我想要实现的是:如果设备无法访问:跳到下一个。如果设备没有正确的 OID:跳到下一个。

目前,当它发生时,我有一个像这样的错误: 错误 SnmpSharpNet.SnmpNetworkException: '网络错误:连接被对等方重置。'

引起 SnmpV1Packet 结果 = (SnmpV1Packet)target.Request(pdu, param);

我的代码示例

//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");
 }

感谢您的帮助

【问题讨论】:

    标签: connection snmpsharpnet


    【解决方案1】:

    我遇到了同样的问题,解决方案是在你的窗口上安装 SNMP 服务,它应该可以正常工作了

    这个链接应该可以帮助你https://support.microsoft.com/en-us/help/324263/how-to-configure-the-simple-network-management-protocol-snmp-service-i

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-07
      • 2017-06-09
      • 1970-01-01
      • 2020-12-22
      • 2017-12-22
      • 1970-01-01
      相关资源
      最近更新 更多