raihanafroz / zkteco

ZKTeco Laravel Library
151 stars 57 forks source link

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

Open haripaudyel opened 3 years ago

haripaudyel commented 3 years ago

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

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

gegejosper commented 3 years ago

same issue here.. how do you fix it?

mariam-abolsoud commented 3 years ago

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

ahmeraq commented 3 years ago

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

kingw1 commented 3 years ago

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

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

saydfuad commented 2 years ago

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

adawey commented 1 year ago

any selution ?

davidmcglynn commented 1 year ago

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();