Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZKError: TIMEOUT_ON_WRITING_MESSAGE upon client socket reconnect. #27

Open
edwin1028 opened this issue Oct 1, 2020 · 8 comments
Open

Comments

@edwin1028
Copy link

edwin1028 commented Oct 1, 2020

Good day! I'm attempting to connect multiple devices and use socket.io to emit data to client side. At first load of the server everything works fine, It say's "ok tcp" and "ok udp" but after/upon reloading the client app im having a problem with the udp type device. Here is the error:

 ZKError {
      err: Error: TIMEOUT_ON_WRITING_MESSAGE
      at Timeout.<anonymous> (C:\workspace\zktime-logs\backend\node_modules\node-zklib\zklibudp.js:101:20)
      at listOnTimeout (internal/timers.js:531:17)
      at processTimers (internal/timers.js:475:7),
      ip: 'XXX.XXX.XX.XX',
      command: '[UDP] undefined'
 }

Here is my code below:

constructor(server) {
    this.io = sio.listen(server);
    this.io
      .on("connection", (socket) => {
        devices.forEach(async (device, index) => {
          const zkInstance = new ZKLib(device.ip, 4370, 10000, 4000);
          try {
            await zkInstance.createSocket();
            console.log(await zkInstance.getInfo());

            await zkInstance.getRealTimeLogs((data) => {
              console.log(data);
            });
          } catch (e) {
            console.log(e);
            if (e.code === 'EADDRINUSE') {
            }
          }
        });
      });
  }

Thank you in advance for the help!

@Benitez25
Copy link

Hello, did you solve the problem?. That happens to me too

@zhfahan77
Copy link

any update facing same problem here,

image

@fernandomonterroso
Copy link

Tengo el mismo problema.

@jmikepaz
Copy link

same problem when try zkInstance.getTime()

@jmikepaz
Copy link

same problem when try zkInstance.getTime()
new ZKLib(address, port, timeout , inport);
I resolve error timeout = 10000;

@merouanezouaid
Copy link

any update facing same problem here,

image

I fixed it you just need to remove await in the timeout method and it works perfectly fine for me

The code is in zklibtcp.js file:

writeMessage(msg, connect) {
    return new Promise((resolve, reject) => {

      let timer = null
      this.socket.once('data', (data) => {
        timer && clearTimeout(timer)
        resolve(data)
      })

      this.socket.write(msg, null, async (err) => {
        if (err) {
          reject(err)
        } else if (this.timeout) {
          timer = setTimeout(() => {
            clearTimeout(timer);
            reject(new Error('TIMEOUT_ON_WRITING_MESSAGE'));
          }, connect ? 2000 : this.timeout)
        }
      })
    })
  }

I updated some functionalities and resolved most of the issues in my module based on this package
Feel free to check it out:
https://github.com/merouanezouaid/zklib-js

@marwanzak
Copy link

had anyone solve it yet? I have the same issue with some devices and not all of them

@beatrx30
Copy link

My case is my ZKteco G2 was offline so i can't make a TCP connect to it, even though i can ping to the device 's IP. So make sure your device is online and be abled to connect. And If other computer is connecting to the attendence device, you still can connect to it by TCP, i dont use UDP so i don't know if it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants