canhlinh / gozk

The unofficial library of zksoftware the fingerprint attendance machine is written by golang
MIT License
13 stars 19 forks source link

unable to authenticate TCP #12

Open binar1 opened 2 years ago

binar1 commented 2 years ago

Hi , I faced an issue while using this library with iface 1000 zk device ,It will return panic: unauthorized
Heres My code:

func ZkRun() {
    zkSocket := gozk.NewZK("10.20.0.7", 4370, 0, gozk.DefaultTimezone)
    if err := zkSocket.Connect(); err != nil {
        panic(err)
    }

    c, err := zkSocket.LiveCapture()
    if err != nil {
        panic(err)
    }

    go func() {
        for event := range c {
            log.Println(event)
        }
    }()

    gracefulQuit(zkSocket.StopCapture)
}

func gracefulQuit(f func()) {
    sigChan := make(chan os.Signal)
    signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
    go func() {
        <-sigChan

        log.Println("Stopping...")
        f()

        time.Sleep(time.Second * 1)
        os.Exit(1)
    }()

    for {
        time.Sleep(10 * time.Second) 
    }
}

but when i am testing with pyzk library every thing is fine

canhlinh commented 2 years ago

@binar1 Is your device has password ?

binar1 commented 2 years ago

@canhlinh No, password was not assigned

dfsRony commented 2 years ago

I also face this issue right now, any suggestion how to resolve this?

canhlinh commented 2 years ago

I'll check it when have time.

yusrenaltair commented 2 years ago

Any update on this? I've trying for ZKTeco Uface202 Plus; some devices can be connected; some more are having this problem.

canhlinh commented 2 years ago

@young-altair I can not check this issue due to the lack of test devices. =))

yusrenaltair commented 1 year ago

@young-altair I can not check this issue due to the lack of test devices. =)) As it turned out, I only needed to delete row number 77 https://github.com/canhlinh/gozk/blob/e7857c178ba689934d2d8cb9252babb1b7e6a065/zk.go#L77 to line 87 https://github.com/canhlinh/gozk/blob/e7857c178ba689934d2d8cb9252babb1b7e6a065/zk.go#L87 and now it works!

canhlinh commented 1 year ago

@young-altair Got cha. but without test devices. I can not make a decision. Because this code till works with my device

ahmedibra28 commented 9 months ago

I'm also having the same issue: "unauthorized." My device is ZKTeco U270

canhlinh commented 9 months ago

@ahmedibra28 Could you test with this lib https://github.com/fananimi/pyzk