AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
5.07k stars 406 forks source link

Fix panic for homekit source (nil conn) #628

Closed buchvald closed 1 year ago

buchvald commented 1 year ago

Hi AlexxIT

I have updated to newest version.

Here is the error:

22:18:15.943 INF go2rtc version 1.7.1 linux/amd64
22:18:15.944 INF [api] listen addr=0.0.0.0:1984
22:18:15.945 INF [rtsp] listen addr=0.0.0.0:8554
22:18:15.945 INF [webrtc] listen addr=0.0.0.0:8555/tcp
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x673425]
goroutine 6 [running]:
bufio.(*Writer).Flush(0xc0002767c0)
    bufio/bufio.go:642 +0x45
net/http.(*Request).write(0xc000143000, {0x0, 0x0}, 0x0, 0x0, 0x0)
    net/http/request.go:747 +0xc77
net/http.(*Request).Write(...)
    net/http/request.go:540
github.com/AlexxIT/go2rtc/pkg/hap.(*Client).Do(0xc000348400, 0x1134520?)
    github.com/AlexxIT/go2rtc/pkg/hap/client_http.go:22 +0x4d
github.com/AlexxIT/go2rtc/pkg/hap.(*Client).Request(0xc000348400, {0xb9f21b, 0x3}, {0xba6906, 0xc}, {0x0, 0x0}, {0x0, 0x0})
    github.com/AlexxIT/go2rtc/pkg/hap/client_http.go:38 +0x1bf
github.com/AlexxIT/go2rtc/pkg/hap.(*Client).Get(...)
    github.com/AlexxIT/go2rtc/pkg/hap/client_http.go:47
github.com/AlexxIT/go2rtc/pkg/hap.(*Client).GetAccessories(0x410225?)
    github.com/AlexxIT/go2rtc/pkg/hap/client.go:232 +0x3c
github.com/AlexxIT/go2rtc/pkg/hap.(*Client).GetFirstAccessory(0xb20c60?)
    github.com/AlexxIT/go2rtc/pkg/hap/client.go:246 +0x13
github.com/AlexxIT/go2rtc/pkg/hap/camera.(*Stream).GetFreeStream(0xc0000a1180)
    github.com/AlexxIT/go2rtc/pkg/hap/camera/stream.go:74 +0x25
github.com/AlexxIT/go2rtc/pkg/hap/camera.NewStream(0xc000348400, 0xc0000a5180, 0xc0000a51d0, 0xc0000d0e70, 0xc0000d0f20)
    github.com/AlexxIT/go2rtc/pkg/hap/camera/stream.go:25 +0xdc
github.com/AlexxIT/go2rtc/pkg/homekit.(*Client).Start(0xc000036680)
    github.com/AlexxIT/go2rtc/pkg/homekit/client.go:135 +0x5c5
github.com/AlexxIT/go2rtc/internal/streams.(*Producer).worker(0xc0001542d0, {0xcaed28?, 0xc000036680?}, 0x1)
    github.com/AlexxIT/go2rtc/internal/streams/producer.go:162 +0x2f
created by github.com/AlexxIT/go2rtc/internal/streams.(*Producer).reconnect in goroutine 54
    github.com/AlexxIT/go2rtc/internal/streams/producer.go:239 +0x4fd
buchvald commented 1 year ago

Config:

streams:
    entrecam: hass:Entrecam 
    bryggerscam: hass:Bryggerscam
AlexxIT commented 1 year ago

What models of your cameras? Are they works before update?

buchvald commented 1 year ago

Both cameras are Aqara G2H. They are connected via "HomeKit Device" in Home Assistant.

The setup has worked with ver 1.6.2

AlexxIT commented 1 year ago

Ok. I have this model. But unpacked yet.

AlexxIT commented 1 year ago

https://github.com/AlexxIT/go2rtc/releases/tag/v1.8.0

buchvald commented 1 year ago

It works. Thanks 🙏🏻