vincentbernat / dashkiosk

Managing dashboards on various displays (especially those running on Android)
Other
365 stars 63 forks source link

Chromecast built-in devices won't show up in the admin menu #102

Open kamils85 opened 4 years ago

kamils85 commented 4 years ago

Hello,

Similar issue to #99 but it's now working for me. I run Docker version of the kiosk and I can see the device in the cli but it's not showing up in the admin menu.

./node_modules/nodecastor/bin/chromecast discover  
info: + tv1 (192.168.15.29:8009) [7a45c2096bd3c44e54babb002af33ea4]
avahi-browse -vr  _googlecast._tcp                     
Server version: avahi 0.6.32; Host name: librenms.local
E Ifce Prot Name                                          Type                 Domain
+  ens32 IPv4 BeyondTV-7a45c2096bd3c44e54babb002af33ea4     _googlecast._tcp     local
=  ens32 IPv4 BeyondTV-7a45c2096bd3c44e54babb002af33ea4     _googlecast._tcp     local
   hostname = [7a45c209-6bd3-c44e-54ba-bb002af33ea4.local]
   address = [192.168.15.29]
   port = [8009]
   txt = ["rs=" "nf=1" "bs=FA8F708A40EA" "st=0" "ca=198661" "fn=tv1" "ic=/setup/icon.png" "md=BeyondTV" "ve=05" "rm=" "cd=D4FCF4819E8C3DFB47F494EA2E25E467" "id=7a45c2096bd3c44e54babb002af33ea4"]
: All for now
getent hosts 7a45c209-6bd3-c44e-54ba-bb002af33ea4.local
192.168.15.29   7a45c209-6bd3-c44e-54ba-bb002af33ea4.local
root@librenms:~# docker logs c
Starting system message bus: dbus.
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>
There are no pending migrations.
{"id":1,"name":"Unassigned","description":"Default group for unassigned displays","level":"info","message":"starting group","timestamp":"2020-10-15T18:22:40.323Z"}
{"level":"info","message":"Express server listening on port 8081 in production mode","timestamp":"2020-10-15T18:22:40.345Z"}
{"group":{"id":1,"name":"Unassigned","description":"Default group for unassigned displays"},"dashboard":{"id":1,"url":"/unassigned","description":"Dashboards for unassigned display","timeout":null,"viewport":null,"delay":null,"availability":null,"group":1,"active":true},"level":"info","message":"new dashboard to display","timestamp":"2020-10-15T18:22:40.350Z"}
{"address":"192.168.15.29","port":8009,"id":"7a45c2096bd3c44e54babb002af33ea4","friendlyName":"tv1","level":"info","message":"New Chromecast device discovered","timestamp":"2020-10-15T18:22:40.487Z"}
{"level":"info","message":"Rescan Chromecast devices","timestamp":"2020-10-15T18:24:40.372Z"}
{"level":"info","message":"Rescan Chromecast devices","timestamp":"2020-10-15T18:26:40.401Z"}
{"level":"info","message":"Rescan Chromecast devices","timestamp":"2020-10-15T18:28:40.423Z"}
{"level":"info","message":"Rescan Chromecast devices","timestamp":"2020-10-15T18:30:40.443Z"}
{"level":"info","message":"Rescan Chromecast devices","timestamp":"2020-10-15T18:32:40.451Z"}
{"level":"info","message":"Rescan Chromecast devices","timestamp":"2020-10-15T18:34:40.470Z"}
{"level":"info","message":"Rescan Chromecast devices","timestamp":"2020-10-15T18:36:40.500Z"}

Would really appreciate any advice :)

vincentbernat commented 4 years ago

Unless you use --net=host, containers cannot see the Chromecasts.

kamils85 commented 4 years ago

I did run it with --net=host option enabled hence the logs showing the device. It's just the admin portal that won't show them.

I have also tried with manual installation (not the docker) and it's the same. The TV's are being discovered by the avahi driver but the admin page still won't show them :/

vincentbernat commented 4 years ago

It seems the device was detected at some point but is not anymore. I don't have much clue as why nodecastor is able to see it and not dashkiosk... Maybe update mdns package?

kamils85 commented 4 years ago

Is there a cli command I can use to send a test url to the chromcast device?

vincentbernat commented 4 years ago

You can try with nodecastor. But nodecastor sees the Chromecast while Dashkiosk doesn't.

kamils85 commented 4 years ago

I have updated the mdns package to the lastest but still no luck. What's the best way to debug Dashkiosk?

vincentbernat commented 4 years ago

At https://github.com/vincentbernat/dashkiosk/blob/master/lib/chromecast.js#L133, you see you should get a log message when a new device is detected. You don't get it. It's called from https://github.com/vincentbernat/dashkiosk/blob/master/server.js#L41. Just to be sure, you did specifically enable Chromecast support (either in config file or on command line)?

kamils85 commented 4 years ago

I do get it. If I switch on more TVs I get more logs that they have been discovered unless we are talking about different things.

{"address":"192.168.15.29","port":8009,"id":"7a45c2096bd3c44e54babb002af33ea4","friendlyName":"tv1","level":"info","message":"New Chromecast device discovered","timestamp":"2020-10-15T18:22:40.487Z"}

Just not sure where to go next.

vincentbernat commented 4 years ago

Oh, I have missed this! With nodecastor's chromecast, can you check the status of the Chromecast? Something like:

bin/chromecast status 192.168.15.29 8009
kamils85 commented 4 years ago
info: Status received: 
{ applications:
   [ { appId: 'E8C28D3C',
       appType: 'WEB',
       displayName: 'Backdrop',
       iconUrl: '',
       isIdleScreen: true,
       launchedFromCloud: false,
       namespaces:
        [ { name: 'urn:x-cast:com.google.cast.debugoverlay' },
          { name: 'urn:x-cast:com.google.cast.cac' },
          { name: 'urn:x-cast:com.google.cast.sse' },
          { name: 'urn:x-cast:com.google.cast.remotecontrol' } ],
       sessionId: '86a380a9-b589-4ddb-bb4f-2f6c296eb8ca',
       statusText: '',
       transportId: '86a380a9-b589-4ddb-bb4f-2f6c296eb8ca',
       universalAppId: 'E8C28D3C' } ],
  userEq: {},
  volume:
   { controlType: 'master',
     level: 0.05000000074505806,
     muted: false,
     stepInterval: 0.009999999776482582 } }
vincentbernat commented 4 years ago

It seems OK. Can you run Dashkiosk with log.level set to debug? It should tell more why it doesn't handle the Chromecast.

kamils85 commented 4 years ago

I will try to set it up but just to let you know my TV just got discovered few minutes ago.

Now the status looks like this:

info: Status received: 
{ applications:
   [ { appId: '5E7A2C2C',
       appType: 'WEB',
       displayName: 'Dashkiosk Chromecast receiver',
       iconUrl: '',
       isIdleScreen: false,
       launchedFromCloud: false,
       namespaces:
        [ { name: 'urn:x-cast:com.google.cast.debugoverlay' },
          { name: 'urn:x-cast:com.google.cast.cac' },
          { name: 'urn:x-cast:com.deezer.cast.dashkiosk' } ],
       sessionId: '7a21922e-96e2-44e2-b64f-5b6d75009df8',
       statusText:
        'Receiver: http://192.168.15.30:8081/receiver#register=Gde4LPXIy6U5aBZwDeZdrtahxPfJykwFmYzlCwpQEmU=|1602816549|BGMp35pFFg4KTQ==|Aje39vTzvAKuoKUSwSPCWA==|YmvVvro5iD5xQowahwsC1AkTtrQbBu0y1OtnqxHst7uWQ6s7jnnrnXv0fyj2Dr5ZhdQ0gVc+aoYAUEkvCfeD7Q==',
       transportId: '7a21922e-96e2-44e2-b64f-5b6d75009df8',
       universalAppId: '5E7A2C2C' } ],
  isActiveInput: true,
  isStandBy: false,
  userEq: {},
  volume:
   { controlType: 'master',
     level: 0.05000000074505806,
     muted: false,
     stepInterval: 0.009999999776482582 } }
kamils85 commented 4 years ago

Ok, yesterday all the Chromcast TV's appeared on the admin menu but after rebooting them they are no longer visible and we're back to where we started.

I have enabled the debug logs and here is the result:

{"level":"info","message":"Rescan Chromecast devices","timestamp":"2020-10-21T13:31:22.446Z"}
{"protocol_version":0,"source_id":"sender-1IAXXNFV3L","destination_id":"receiver-0","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":"STRING","payload_utf8":"{\"type\":\"PING\"}","payload_binary":null,"level":"debug","message":"Sent to Chromecast","timestamp":"2020-10-21T13:31:23.073Z"}
{"protocol_version":0,"source_id":"sender-JBJO3P7UJM","destination_id":"receiver-0","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":"STRING","payload_utf8":"{\"type\":\"PING\"}","payload_binary":null,"level":"debug","message":"Sent to Chromecast","timestamp":"2020-10-21T13:31:23.074Z"}
{"protocol_version":0,"source_id":"sender-ICB1E6EI8T","destination_id":"receiver-0","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":"STRING","payload_utf8":"{\"type\":\"PING\"}","payload_binary":null,"level":"debug","message":"Sent to Chromecast","timestamp":"2020-10-21T13:31:23.075Z"}
{"protocol_version":0,"source_id":"sender-H3RY5YYAQ1","destination_id":"receiver-0","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":"STRING","payload_utf8":"{\"type\":\"PING\"}","payload_binary":null,"level":"debug","message":"Sent to Chromecast","timestamp":"2020-10-21T13:31:23.115Z"}
{"protocol_version":0,"source_id":"receiver-0","destination_id":"sender-1IAXXNFV3L","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":0,"payload_utf8":"{\"type\":\"PONG\"}","payload_binary":null,"level":"debug","message":"Received from Chromecast","timestamp":"2020-10-21T13:31:23.153Z"}
{"protocol_version":0,"source_id":"receiver-0","destination_id":"sender-JBJO3P7UJM","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":0,"payload_utf8":"{\"type\":\"PONG\"}","payload_binary":null,"level":"debug","message":"Received from Chromecast","timestamp":"2020-10-21T13:31:23.153Z"}
{"protocol_version":0,"source_id":"receiver-0","destination_id":"sender-ICB1E6EI8T","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":0,"payload_utf8":"{\"type\":\"PONG\"}","payload_binary":null,"level":"debug","message":"Received from Chromecast","timestamp":"2020-10-21T13:31:23.154Z"}
{"protocol_version":0,"source_id":"receiver-0","destination_id":"sender-H3RY5YYAQ1","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":0,"payload_utf8":"{\"type\":\"PONG\"}","payload_binary":null,"level":"debug","message":"Received from Chromecast","timestamp":"2020-10-21T13:31:23.155Z"}
{"protocol_version":0,"source_id":"sender-1IAXXNFV3L","destination_id":"receiver-0","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":"STRING","payload_utf8":"{\"type\":\"PING\"}","payload_binary":null,"level":"debug","message":"Sent to Chromecast","timestamp":"2020-10-21T13:31:53.154Z"}
{"protocol_version":0,"source_id":"sender-JBJO3P7UJM","destination_id":"receiver-0","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":"STRING","payload_utf8":"{\"type\":\"PING\"}","payload_binary":null,"level":"debug","message":"Sent to Chromecast","timestamp":"2020-10-21T13:31:53.156Z"}
{"protocol_version":0,"source_id":"sender-ICB1E6EI8T","destination_id":"receiver-0","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":"STRING","payload_utf8":"{\"type\":\"PING\"}","payload_binary":null,"level":"debug","message":"Sent to Chromecast","timestamp":"2020-10-21T13:31:53.156Z"}
{"protocol_version":0,"source_id":"receiver-0","destination_id":"sender-1IAXXNFV3L","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":0,"payload_utf8":"{\"type\":\"PONG\"}","payload_binary":null,"level":"debug","message":"Received from Chromecast","timestamp":"2020-10-21T13:31:53.160Z"}
{"protocol_version":0,"source_id":"receiver-0","destination_id":"sender-JBJO3P7UJM","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":0,"payload_utf8":"{\"type\":\"PONG\"}","payload_binary":null,"level":"debug","message":"Received from Chromecast","timestamp":"2020-10-21T13:31:53.161Z"}
{"protocol_version":0,"source_id":"sender-H3RY5YYAQ1","destination_id":"receiver-0","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":"STRING","payload_utf8":"{\"type\":\"PING\"}","payload_binary":null,"level":"debug","message":"Sent to Chromecast","timestamp":"2020-10-21T13:31:53.162Z"}
{"protocol_version":0,"source_id":"receiver-0","destination_id":"sender-ICB1E6EI8T","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":0,"payload_utf8":"{\"type\":\"PONG\"}","payload_binary":null,"level":"debug","message":"Received from Chromecast","timestamp":"2020-10-21T13:31:53.163Z"}
{"protocol_version":0,"source_id":"receiver-0","destination_id":"sender-H3RY5YYAQ1","namespace":"urn:x-cast:com.google.cast.tp.heartbeat","payload_type":0,"payload_utf8":"{\"type\":\"PONG\"}","payload_binary":null,"level":"debug","message":"Received from Chromecast","timestamp":"2020-10-21T13:31:53.166Z"}

Also when I cast from Chrome browser to the TV I see this in logs:

{"protocol_version":0,"source_id":"receiver-0","destination_id":"*","namespace":"urn:x-cast:com.google.cast.receiver","payload_type":0,"payload_utf8":"{\"requestId\":0,\"status\":{\"userEq\":{},\"volume\":{\"controlType\":\"master\",\"level\":0.10000000149011612,\"muted\":false,\"stepInterval\":0.009999999776482582}},\"type\":\"RECEIVER_STATUS\"}","payload_binary":null,"level":"debug","message":"Received from Chromecast","timestamp":"2020-10-21T13:34:53.535Z"}
{"id":"7a45c2096bd3c44e54babb002af33ea4","chromecast":"tv1","level":"debug","message":"Chromecast device is NOT on home screen","timestamp":"2020-10-21T13:34:53.539Z"}
{"protocol_version":0,"source_id":"receiver-0","destination_id":"*","namespace":"urn:x-cast:com.google.cast.receiver","payload_type":0,"payload_utf8":"{\"requestId\":0,\"status\":{\"userEq\":{},\"volume\":{\"controlType\":\"master\",\"level\":0.10000000149011612,\"muted\":false,\"stepInterval\":0.009999999776482582}},\"type\":\"RECEIVER_STATUS\"}","payload_binary":null,"level":"debug","message":"Received from Chromecast","timestamp":"2020-10-21T13:34:53.553Z"}
{"id":"7a45c2096bd3c44e54babb002af33ea4","chromecast":"tv1","level":"debug","message":"Chromecast device is NOT on home screen","timestamp":"2020-10-21T13:34:53.553Z"}

at the moment all my Chromcast devices show this status:

info: Status received:
{ userEq: {},
  volume:
   { controlType: 'master',
     level: 0.10000000149011612,
     muted: false,
     stepInterval: 0.009999999776482582 } }

I can ping them by dns name in case this helps

ping 1ac20f47-3f80-2881-205f-d05b3ef6f625.local
PING 1ac20f47-3f80-2881-205f-d05b3ef6f625.local (192.168.15.29) 56(84) bytes of data.
64 bytes from Android-4.local (192.168.15.29): icmp_seq=1 ttl=64 time=1.78 ms
64 bytes from Android-4.local (192.168.15.29): icmp_seq=2 ttl=64 time=1.55 ms
64 bytes from Android-4.local (192.168.15.29): icmp_seq=3 ttl=64 time=1.80 ms
64 bytes from Android-4.local (192.168.15.29): icmp_seq=4 ttl=64 time=1.76 ms

any other suggestions?

kamils85 commented 4 years ago

@vincentbernat I managed to get it to work only if I manually run this command:

chromecast dashkiosk 192.168.15.29 https://anywebsite.com

Once I've done that the device appears on the admin portal and I can move to a group. I ran this command for all my TVs and they all came up on the dashkiosk however if I switch the TV off and back on again I need to run this command again to make them online if that makes sense.

Appreciate your help so far. Do you have any more suggestions?

I've also noticed that the dashkiosk likes to crash very often when I disconnect my TVs from the network but that's probably another issue.

":44,"15132":34,"15133":49,"15134":51,"15135":54,"15136":53,"15137":34,"15138":58,"15139":49,"15140":48,"15141":49,"15142":44,"15143":34,"15144":49,"15145":51,"15146":54,"15147":54,"15148":34,"15149":58,"15150":49,"15151":49,"15152":52,"15153":44,"15154":34,"15155":49,"15156":51,"15157":54,"15158":55,"15159":34,"15160":58,"15161":51,"15162":52,"15163":44,"15164":34,"15165":49,"15166":51,"15167":54,"15168":56,"15169":34,"15170":58,"15171":53,"15172":56,"15173":44,"15174":34,"15175":49,"15176":51,"15177":54,"15178":57,"15179":34,"15180":58,"15181":57,"15182":49,"15183":44,"15184":34,"15185":49,"15186":51,"15187":55,"15188":48,"15189":34,"15190":58,"15191":57,"15192":51,"15193":44,"15194":34,"15195":49,"15196
<--- Last few GCs --->

[1:0x3a6f040]   864603 ms: Scavenge 616.6 (644.4) -> 600.8 (644.4) MB, 0.8 / 0.0 ms  (average mu = 0.976, current mu = 0.966) allocation failure 
[1:0x3a6f040]   864624 ms: Scavenge 616.6 (644.4) -> 600.8 (644.4) MB, 0.9 / 0.0 ms  (average mu = 0.976, current mu = 0.966) allocation failure 
[1:0x3a6f040]   864646 ms: Scavenge 616.6 (644.4) -> 600.8 (644.4) MB, 0.8 / 0.0 ms  (average mu = 0.976, current mu = 0.966) allocation failure 

<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x2a066305be1d]
Security context: 0x0d3fbb19e6e9 <JSObject>
    1: derez(aka derez) [0x35fc3b882241] [/dashkiosk/dist/node_modules/cycle/cycle.js:~46] [pc=0x2a066337bacf](this=0x23a664a026f1 <undefined>,value=0x25bb1d983a91 <Uint8Array map = 0x207c53e05539>,path=0x0954cd473999 <String[170]: $["logger"]["transports"]["file"]["_stream"]["_writableState"]["bufferedRequest"]["next"]["next"]["next"]["next"]["next"]["next"...

FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory
 1: 0x8fa0c0 node::Abort() [node]
 2: 0x8fa10c  [node]
 3: 0xb0026e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xb004a4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xef49b2  [node]
 6: 0x1059baa v8::internal::OrderedHashTable<v8::internal::OrderedHashSet, 1>::Allocate(v8::internal::Isolate*, int, v8::internal::PretenureFlag) [node]
 7: 0x105cdfb v8::internal::OrderedHashTable<v8::internal::OrderedHashSet, 1>::Rehash(v8::internal::Handle<v8::internal::OrderedHashSet>, int) [node]
 8: 0x105d3c9 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet, 1>::EnsureGrowable(v8::internal::Handle<v8::internal::OrderedHashSet>) [node]
 9: 0x105d4c0 v8::internal::OrderedHashSet::Add(v8::internal::Handle<v8::internal::OrderedHashSet>, v8::internal::Handle<v8::internal::Object>) [node]
10: 0xfcf6f5 v8::internal::KeyAccumulator::AddKey(v8::internal::Handle<v8::internal::Object>, v8::internal::AddKeyConversion) [node]
11: 0xe6e7a0  [node]
12: 0xfd16ab v8::internal::KeyAccumulator::CollectOwnElementIndices(v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::JSObject>) [node]
13: 0xfd2b12 v8::internal::KeyAccumulator::CollectOwnKeys(v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::JSObject>) [node]
14: 0xfd37d5 v8::internal::KeyAccumulator::CollectKeys(v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::JSReceiver>) [node]
15: 0xfd3c03 v8::internal::FastKeyAccumulator::GetKeys(v8::internal::GetKeysConversion) [node]
16: 0x115d533 v8::internal::Runtime_ForInEnumerate(int, v8::internal::Object**, v8::internal::Isolate*) [node]
17: 0x2a066305be1d 
vincentbernat commented 4 years ago

Sorry for not helping. 644 MB seems to be a lot and there may be a leak somewhere. I didn't run into this issue, but I am not using Chromecasts since a long time. Dashkiosk works for me, but the code is getting pretty old, depending on old versions of many libraries and I have no time and no motivation to update. JS is not my favorite language and the ecosystem moves too fast for me. I am just saying that for you not to spend too much time on trying to make it work.

So, for the leak, no clue. For the problem to detect Chromecast, your best bet is to add many logger.info() into chromecast.js and see what step is missing to detect the Chromecasts. It seems the problem is on the detection of the Chromecast being on the homepage, but the status command you got is correct, it shows E8C28D3C as the ID of the current app and it should be enough to detect it's on homescreen and therefore to take control of them. Moreover, you should get a debug message and your last debug trace didn't show that.