brutella / hap

The HomeKit Accessory Protocol (hap) implemented in Go
Apache License 2.0
356 stars 43 forks source link

Fix error handling #1

Closed asedov closed 2 years ago

asedov commented 2 years ago

This code

...
ctx, cancel := context.WithCancel(context.Background())
go func() {
    time.Sleep(time.Second) 
    cancel()
}()

err = server.ListenAndServe(ctx)
if err != nil && !errors.Is(err, http.ErrServerClosed) {
    log.Println(err)
}
...

throws false positive errors:

conn.go:83: decryption failed: read tcp 192.168.1.2:38891->192.168.1.3:58876: use of closed network connection
conn.go:83: decryption failed: read tcp 192.168.1.2:38891->192.168.1.4:49476: use of closed network connection
accept tcp [::]: 38891: use of closed network connection

Thanks.

brutella commented 2 years ago

Thanks