zkteco icon indicating copy to clipboard operation
zkteco copied to clipboard

unpack(): Type H: not enough input, need 1, have 0

Open haripaudyel opened this issue 3 years ago • 7 comments

I got This Error when I Try to call getUser():

unpack(): Type H: not enough input, need 1, have 0

haripaudyel avatar Mar 16 '21 07:03 haripaudyel

same issue here.. how do you fix it?

gegejosper avatar Mar 24 '21 07:03 gegejosper

same issue with me .. did you fix it ??

mariam-abolsoud avatar Apr 12 '21 13:04 mariam-abolsoud

I'm also having the same issue. anyone found the solution or have any idea ?

ahmeraq avatar May 16 '21 00:05 ahmeraq

you should call $zk->connect(); before call $zk->getUser(); like this

$zk = new ZKTeco(your device ip); $zk->connect(); $users = $zk->getUser(); dd($users);

kingw1 avatar Jun 29 '21 06:06 kingw1

Make sure you can ping and telnet to your device first, most of the time is because the device is not connected yet.

ping YOUR-IP telnet YOUR-IP 4370

saydfuad avatar Aug 11 '22 08:08 saydfuad

any selution ?

adawey avatar Oct 13 '22 23:10 adawey

I think this is more of a usage/documentation error, not a functionality issue.

It appears that the library does not internally store whether or not the connect() call was successful. (and FYI, the timeout is set to 60 seconds before it will give up) It leaves it up to you to verify it.

To catch this condition, check the result of the connect() call in your code, to prevent any operations like "getUser" or "getAttendance" unless the connect() method returned true:

$zk = new \Rats\Zkteco\Lib\ZKTeco( <ip_addr> );
if (!$zk->connect()) {
  print "Couldn't connect!";
  exit;
} else {
  print "Connected.";
}
// connection verified .. continue on with program
$zk->getAttendance();

davidmcglynn avatar Mar 20 '23 13:03 davidmcglynn