MMM-Screencast icon indicating copy to clipboard operation
MMM-Screencast copied to clipboard

Screencast somehow collides with Remote Control API and the Integration to Home Assistant

Open fribse opened this issue 3 years ago • 7 comments

Yeah, I know this is fluffy. There is an integration into Home Assistant that uses the Remote Control API. If I activate the ScreenCast module, the integration doesn't work. I'm posting it here, but I will of course also post it in the Home Assistant Integration. Maybe you can explain me how this might happen, so I can explain it to the developer of the integration?

fribse avatar Feb 13 '22 19:02 fribse

@fribse Hmm my intial guess would be a port collision or something similar. Do you have any logs of this? and what exactly are you using for Home Assistant and Remote Control? I might have some time to dig into this.

kevinatown avatar Feb 16 '22 17:02 kevinatown

Odd, Remote control uses port 8080, where can I find some extra log files?

fribse avatar Feb 16 '22 17:02 fribse

Open ports without ScreenCast module active:

pi@bathmirror:~ $ netstat -atu
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 bathmirror.fri:http-alt 0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN
tcp        0      0 bathmirror.friber:49176 37.139.1.159:https      ESTABLISHED
tcp        0      0 bathmirror.friber:49178 37.139.1.159:https      ESTABLISHED
tcp        0      0 bathmirror.friber:32846 lb-140-82-121-4-f:https TIME_WAIT
tcp        0      0 bathmirror.fri:http-alt homeassistant.fri:43402 TIME_WAIT
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45050 ESTABLISHED
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45264 FIN_WAIT2
tcp        0      0 bathmirror.friber:32848 lb-140-82-121-4-f:https TIME_WAIT
tcp        0      0 bathmirror.friber:32850 lb-140-82-121-4-f:https TIME_WAIT
tcp        0      0 bathmirror.friber:60630 lb-140-82-121-3-f:https TIME_WAIT
tcp        0      0 bathmirror.friber:45050 bathmirror.fri:http-alt ESTABLISHED
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45236 TIME_WAIT
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45242 TIME_WAIT
tcp        1      0 bathmirror.friber:45264 bathmirror.fri:http-alt CLOSE_WAIT
tcp        0    256 bathmirror.fribert.:ssh Lear.fribert.dk:59236   ESTABLISHED
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*
udp        0      0 0.0.0.0:51298           0.0.0.0:*
udp   140800      0 0.0.0.0:mdns            0.0.0.0:*

fribse avatar Feb 16 '22 18:02 fribse

With ScreenCast in there are a lot more ports:

pi@bathmirror:~ $ netstat -atu
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 bathmirror.fri:http-alt 0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8569            0.0.0.0:*               LISTEN
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55360 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55413 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55425 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55342 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55374 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55383 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55352 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55359 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55344 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55414 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55339 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55423 TIME_WAIT
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45296 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55271 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55412 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55259 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55398 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55294 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55378 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55273 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55400 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55357 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55442 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55293 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55358 TIME_WAIT
tcp        0      0 bathmirror.friber:60696 lb-140-82-121-3-f:https TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55279 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55289 TIME_WAIT
tcp        0      0 bathmirror.friber:49248 37.139.1.159:https      ESTABLISHED
tcp        0      0 bathmirror.fribert:8569 raspberrypi.fribe:37976 FIN_WAIT2
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55288 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55422 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55295 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55356 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55255 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55277 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55334 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55385 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55252 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55377 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55341 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55354 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55353 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55404 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55418 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55287 TIME_WAIT
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45300 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55406 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55424 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55257 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55381 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55278 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55286 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55417 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55421 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55265 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55246 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55297 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55372 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55402 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55371 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55361 TIME_WAIT
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45284 TIME_WAIT
tcp        0      0 bathmirror.friber:36782 cdn-185-199-108-1:https ESTABLISHED
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45330 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55291 TIME_WAIT
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45304 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55403 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55264 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55408 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55280 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55405 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55256 TIME_WAIT
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45332 FIN_WAIT2
tcp        1      0 bathmirror.friber:45332 bathmirror.fri:http-alt CLOSE_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55396 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55399 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55409 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55415 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55266 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55420 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55362 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55355 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55340 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55386 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55338 TIME_WAIT
tcp        0      0 bathmirror.friber:45308 bathmirror.fri:http-alt ESTABLISHED
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55285 TIME_WAIT
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45302 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55343 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55268 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55416 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55364 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55290 TIME_WAIT
tcp        0   1808 bathmirror.fribert.:ssh Lear.fribert.dk:59236   ESTABLISHED
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55419 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55379 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55394 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55382 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55254 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55315 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55284 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55429 TIME_WAIT
tcp        0      0 bathmirror.friber:49250 37.139.1.159:https      ESTABLISHED
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55296 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55292 TIME_WAIT
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45298 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55346 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55407 TIME_WAIT
tcp        0      0 bathmirror.fri:http-alt bathmirror.friber:45308 ESTABLISHED
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55401 TIME_WAIT
tcp        0      0 bathmirror.fri:http-alt homeassistant.fri:45262 TIME_WAIT
tcp        0      0 bathmirror.fribert:8569 AdriansPC.fribert:55410 TIME_WAIT
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*
udp        0      0 bathmirror.friber:50780 0.0.0.0:*
udp        0      0 0.0.0.0:51298           0.0.0.0:*
udp   141504      0 0.0.0.0:mdns            0.0.0.0:*
udp        0      0 0.0.0.0:1900            0.0.0.0:*

Not sure if that helps at all?

fribse avatar Feb 16 '22 18:02 fribse

This list might be better, without ScreenCast:

pi@bathmirror:~ $ netstat -lntup
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 10.11.12.17:8080        0.0.0.0:*               LISTEN      3385/electron.js
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
udp        0      0 0.0.0.0:68              0.0.0.0:*                           -
udp        0      0 0.0.0.0:51298           0.0.0.0:*                           -
udp   136256      0 0.0.0.0:5353            0.0.0.0:*                           -

With screencast:

pi@bathmirror:~ $ netstat -lntup
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 10.11.12.17:8080        0.0.0.0:*               LISTEN      3771/electron.js
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:8569            0.0.0.0:*               LISTEN      3771/electron.js
udp        0      0 0.0.0.0:68              0.0.0.0:*                           -
udp        0      0 0.0.0.0:51298           0.0.0.0:*                           -
udp        0      0 10.11.12.17:50887       0.0.0.0:*                           3771/electron.js
udp   143552      0 0.0.0.0:5353            0.0.0.0:*                           -
udp        0      0 0.0.0.0:1900            0.0.0.0:*                           3771/electron.js

fribse avatar Feb 16 '22 18:02 fribse

I just tested some more together with the @sindrebroch that does the Home Assistant Integration. Weird results.

Without ScreenCast billede I then send requests to RemoteControl API: /api/test: {"success":true} /api/mmUpdateAvailable {"success":true,"query":{"data":"mmUpdateAvailable"},"result":false} /api/monitor/status {"success":true,"monitor":"off"} /api/brightness {"success":true,"query":{"data":"brightness"},"result":100}

With ScreenCast billede RemoteControl API: /api/test: "success":false,"status":"error","reason":"unknown","info":"Not initialized, have you opened or refreshed your browser since the last time you started MagicMirror?"} /api/mmUpdateAvailable {"success":true,"query":{"data":"mmUpdateAvailable"},"result":false} /api/monitor/status {"success":true,"monitor":"on"} /api/brightness {"success":false,"status":"error","reason":"unknown","info":"Not initialized, have you opened or refreshed your browser since the last time you started MagicMirror?"}

Hmmm? So both the module scheduler and the remote-control is somehow affected. I've done a reinstall of MagicMirror, so the only thing left is the Raspberry OS I guess.

fribse avatar Feb 21 '22 13:02 fribse

I just did a complete reinstall on a new SD card. Raspbian Buster, monitor in portrait mode (display_rotate=1). I've tried to install MagicMirror with both sdetwell's script, and manually, the same thing happens. I did a basic MagicMirror install, added the RemoteControl module with API key. As soon as I added ScreenCast it lost the ability to do proper API commands. I tried adding a specific port statement as well to the ScreenCast, just to make sure nothing was coliding, still no joy.

fribse avatar Feb 26 '22 11:02 fribse