TypeError: Cannot read properties of undefined (reading 'subarray') Node JS ZkTeco Biometric Integration

81 Views Asked by At

Hy there,

I am trying to fetch attendance records from zkteco biometric device. I have tried multiple libraries zklib, node-zklib, zk-jubaer, zkh-lib and zklib-32ble but it gives me some strange error.

My Code

const ZKHLIB = require("zkh-lib");

const runMachine = async () => {
  let obj = new ZKHLIB("10.2.3.1", 4370, 5200, 5000);
  try {
    // Create socket to machine
    await obj.createSocket();

    // Get all logs in the machine
    const logs = await obj.getAttendances();
    console.log(logs);

    // Read real-time logs
    await obj.getRealTimeLogs((data) => {
      console.log(data);
    });

    // Disconnect from device
    await obj.disconnect(); // when you are using real-time logs, you need to disconnect manually
  } catch (e) {
    console.log(e);
  }
};

runMachine();

Output Error:

const header = decodeTCPHeader(reply.subarray(0, 16))
                                           ^
TypeError: Cannot read properties of undefined (reading 'subarray')
    at D:\Inventory\socket\node_modules\zkh-lib\src\jtcp.js:246:44

Any help here? Thanks in Advance.

0

There are 0 best solutions below