OpenIPC / majestic

Majestic Community edition integration kit
MIT License
33 stars 5 forks source link

Majestic has no connection retries for outgoing feature #135

Closed YuukiHogo closed 1 year ago

YuukiHogo commented 1 year ago

Board Hi3516cv300 + ar0130

OpenIPC firmware 2.3.09.25 updated from github.

Added 'outgoing' parameter with rtmp:// schema to majestic.yaml.

Issue description

Majestic do connect to a specified URL on startup and does it only once. In case when a network is not ready yet (i.e WiFi), a connection to a host fails to setup. There is no more tries to connect. Only restart of majestic can help. Camera reboot does not help when majestic starts before a network is ready. When a connection to a remote host do brokes (a network or a remote host failure), there is no re-connection either.

Expectations

Majestic retries to connect to a specified URL after each connection failure.

Steps to reproduce

  1. Add to majestic.yaml
    outgoing:
    - rtmp://remote.host/
  2. Start board with network unplugged
  3. Wait 2 minutes
  4. Plug network in
  5. Read majestic logs
widgetii commented 1 year ago

There is no way to resolve the issue using current script-based init system in OpenIPC, Majestic should be started after network inited

As a temporary solution I'd add sleep into majestic script before its start As permanent and robust solution I'd recommend changing init system to runit

YuukiHogo commented 12 months ago

There is no way to resolve the issue using current script-based init system in OpenIPC, Majestic should be started after network inited

I guess issue do not relate to startup system. Majestic must retry connect to remote host on failure with some period.

As a temporary solution I'd add sleep into majestic script before its start As permanent and robust solution I'd recommend changing init system to runit

I have added sleep 10 to S95majestic and it didn't help.

Oct  2 19:22:02 openipc-hi3516cv300 kern.emerg kernel: [   16.723190] Hisilicon Watchdog Timer: 0.01 initialized. default_margin=60 sec (nodeamon= 0)
Oct  2 19:22:02 openipc-hi3516cv300 kern.emerg kernel: [   16.723264] hiwtdg init ok. ver=Jun  3 2018, 21:43:46.
Oct  2 19:22:02 openipc-hi3516cv300 kern.emerg kernel: [   16.796842] RTL871X: start auth
Oct  2 19:22:02 openipc-hi3516cv300 kern.emerg kernel: [   16.800255] RTL871X: auth success, start assoc
Oct  2 19:22:02 openipc-hi3516cv300 kern.emerg kernel: [   16.810026] RTL871X: indicate disassoc
Oct  2 19:22:02 openipc-hi3516cv300 daemon.info hisilicon: Loading video system has started...
Oct  2 19:22:04 openipc-hi3516cv300 kern.emerg kernel: [   18.870051] RTL871X: nolinked power save enter
Oct  2 19:22:11 openipc-hi3516cv300 kern.emerg kernel: [   25.503793] RTL871X: nolinked power save leave
Oct  2 19:22:12 openipc-hi3516cv300 kern.emerg kernel: [   27.090052] RTL871X: nolinked power save enter
Oct  2 19:22:13 openipc-hi3516cv300 daemon.info : starting pid 1112, tty '/dev/console': '/sbin/getty -L console 0 vt100 '
Oct  2 19:22:15 openipc-hi3516cv300 user.info majestic[1109]: Majestic Ultimate for HiSilicon, version master+8fadbc9, built on 2023-09-30
Oct  2 19:22:15 openipc-hi3516cv300 user.info majestic[1109]: Using /etc/majestic.yaml as main configuration
Oct  2 19:22:15 openipc-hi3516cv300 user.debug majestic[1109]: Detected Hisilicon Watchdog
Oct  2 19:22:15 openipc-hi3516cv300 user.debug majestic[1109]: Watchdog timeout set to 10 seconds
Oct  2 19:22:15 openipc-hi3516cv300 user.info majestic[1109]: Using /etc/sensors/imx291_i2c_lvds_1080p_line.ini sensor configuration file
Oct  2 19:22:16 openipc-hi3516cv300 user.info majestic[1109]: linear mode
Oct  2 19:22:16 openipc-hi3516cv300 user.info majestic[1109]: ===IMX291 1080P 30fps 12bit LINE Init OK!===
Oct  2 19:22:16 openipc-hi3516cv300 user.info majestic[1109]: Loading IQ profile /etc/sensors/iq/default.ini
Oct  2 19:22:16 openipc-hi3516cv300 user.info majestic[1109]: HTTP server started on 0.0.0.0:80
Oct  2 19:22:16 openipc-hi3516cv300 user.err majestic[1109]: Failed to join a multicast group '239.255.255.250'
Oct  2 19:22:16 openipc-hi3516cv300 user.err majestic[1109]: Failed to join a multicast group '224.0.0.251'
Oct  2 19:22:16 openipc-hi3516cv300 user.info majestic[1109]: RTSP server started on port 554
Oct  2 19:22:17 openipc-hi3516cv300 user.info majestic[1109]: Connecting to RTMP URL rtmp://REDACTED...
Oct  2 19:22:17 openipc-hi3516cv300 user.err majestic[1109]: RTMP_Connect0, failed to connect socket: unknown error (101)
Oct  2 19:22:17 openipc-hi3516cv300 user.info majestic[1109]: Connection to rtmp://REDACTED failed: -2
Oct  2 19:22:20 openipc-hi3516cv300 kern.emerg kernel: [   34.567303] RTL871X: nolinked power save leave
Oct  2 19:22:21 openipc-hi3516cv300 kern.emerg kernel: [   36.318348] RTL871X: nolinked power save enter
Oct  2 19:22:23 openipc-hi3516cv300 kern.emerg kernel: [   37.832645] RTL871X: nolinked power save leave
Oct  2 19:22:23 openipc-hi3516cv300 kern.emerg kernel: [   37.844790] RTL871X: set ssid [REDACTED] fw_state=0x00000008
Oct  2 19:22:23 openipc-hi3516cv300 kern.emerg kernel: [   37.849880] RTL871X: set bssid:REDACTED
Oct  2 19:22:23 openipc-hi3516cv300 kern.emerg kernel: [   37.891392] RTL871X: start auth
Oct  2 19:22:23 openipc-hi3516cv300 kern.emerg kernel: [   37.895974] RTL871X: auth success, start assoc
Oct  2 19:22:23 openipc-hi3516cv300 kern.emerg kernel: [   37.902610] RTL871X: assoc success
Oct  2 19:22:23 openipc-hi3516cv300 kern.emerg kernel: [   37.917136] RTL871X: send eapol packet
Oct  2 19:22:23 openipc-hi3516cv300 kern.emerg kernel: [   37.929301] RTL871X: send eapol packet
Oct  2 19:22:23 openipc-hi3516cv300 kern.emerg kernel: [   37.947009] RTL871X: set pairwise key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4) camid:4
Oct  2 19:22:23 openipc-hi3516cv300 kern.emerg kernel: [   37.948613] RTL871X: set group key to hw: alg:2(WEP40-1 WEP104-5 TKIP-2 AES-4) keyid:1
widgetii commented 12 months ago

Not in this case, Failed to join a multicast group stands for network is not inited yet before Majestic starts

YuukiHogo commented 12 months ago

Not in this case, Failed to join a multicast group stands for network is not inited yet before Majestic starts

its obvious. But adding sleep 10 to majestic startup script doesn't help (as seen in logs).

Oct  2 19:22:02 openipc-hi3516cv300 daemon.info hisilicon: Loading video system has started...
...
Oct  2 19:22:15 openipc-hi3516cv300 user.info majestic[1109]: Majestic Ultimate for HiSilicon, version master+8fadbc9, built on 2023-09-30
YuukiHogo commented 12 months ago

sleep 30 works ok. But it is VERY bad workaround

widgetii commented 12 months ago

I proposed previously right way to fix it

YuukiHogo commented 12 months ago

I proposed previously right way to fix it

It feels not right way to fix. Kind of better workaround. Majestic do not maintain connection state at all. Any network issue will stop outgoing stream until camera reboot or majestic restart.