生物识别设备ping在一段时间后失败

Muh*_*han 7 c# connection biometrics zkteco zkemkeeper

我有ZKTeco Biometrics设备,它使用本教程(C#ZKTeco生物识别设备入门)与C#windows应用程序连接.

它工作正常,但一段时间后,我的应用程序无法ping通设备.如下面的代码建议,我试图在每25秒后ping一次设备.

  private void TimerCheckPingAndCloseAttendanceForm() {
  timerCheckPingAndCloseAttendanceForm            = new Timer();
  timerCheckPingAndCloseAttendanceForm.Tick       += new EventHandler(CheckPingAndCloseAttendanceForm);
  timerCheckPingAndCloseAttendanceForm.Interval   = 25000;//25 seconds.
  timerCheckPingAndCloseAttendanceForm.Start();
        }


 private void CheckPingAndCloseAttendanceForm(object sender, EventArgs e) {
     string ipAddress = tbxDeviceIP.Text.Trim();
     if (UniversalStatic.PingTheDevice(ipAddress) == false) {
           //CloseAttendaceListForm();
           IsDeviceConnected = false;
           string infoString = "Application started on " + applicationStartDateTime.ToString() + " and ping failed on " + DateTime.Now.ToString() + " then, app closed while device ip is "+ ipAddress;
          File.AppendAllText("ConnectionLog.txt", infoString + Environment.NewLine);
          Application.Exit();
          //timerCheckPingAndCloseAttendanceForm.Tick -= new EventHandler(CheckPingAndCloseAttendanceForm);
            }
        }
Run Code Online (Sandbox Code Playgroud)

当我尝试从cmd ping命令时,设备显示destination host is unreachable.但每当我重启设备时,ping工作正常.我不知道问题出在哪里?网络问题还是编码问题?

注意:我正在定期执行ping操作,因为Disconnected Event无法正常工作.我假设ping失败意味着设备已与应用程序断开连接.

sjb*_*sjb 0

没有实际的代码和硬件设置,这个答案有点盲目,但这里是 \xe2\x80\xa6

\n\n

由于它最初可以工作,因此这不是硬件配置或网络配置问题。但它说,过了一会儿,目的地(阅读器)就变得不可用。这可能不是网络保活问题,因为您每 25 秒 ping 一次。查看您引用的代码,它显示打开连接并连接回调,以及调用硬件功能。

\n\n

我的猜测是,也许您每次 ping 时都会打开连接,而不是关闭连接,然后经过多次尝试后,由于打开的连接太多,硬件出现堵塞。只是一个猜测。如果这是问题所在,那么要修复它,请关闭连接,或者更好的是保持连接打开并重新使用它。

\n\n

另一种可能性是代码和设备之间的路由器检测到过多的 ping 并阻止连接作为可能的 DOS 攻击。如果这是问题,那么要解决它,请将路由器配置为允许流量。

\n