Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting ChromeCast Connect and Disconnect Events #25

Closed
joelongstreet opened this issue Feb 19, 2015 · 6 comments
Closed

Detecting ChromeCast Connect and Disconnect Events #25

joelongstreet opened this issue Feb 19, 2015 · 6 comments

Comments

@joelongstreet
Copy link

Not sure if this is the right place to post this question, but I'm having issues detecting when ChromeCasts join and leave the network.

I originally thought this was a problem with the mdns lib and the way it polled, so I filed an issue. The author of node_mdns helped me out and it looks like the ChromeCast device is the culprit:

  • The first time the app starts, I receive a single serviceUp event for each ChromeCast on the network.
  • If i unplug a ChromeCast, no serviceDown event is sent.
  • If I add new ChromeCasts to the network after the app is started, I get no new serviceUp event.

Not sure if this is related, but after I start and stop my app a few times, I'll have to turn my wifi off and then on again to pick up serviceUps.

Sample App:

var mdns = require('mdns');
var browser = mdns.createBrowser(mdns.tcp('googlecast'));

browser.on('serviceUp', function(service){
  console.log('chromecast detected -', service.name);
});

browser.on('serviceDown', function(service){
  console.log('chromecast lost -', service.name);
});

browser.start();

Thanks for any help you can provide

@thibauts
Copy link
Owner

This is a reccurring issue documented here #22 and here (castnow repo).

I've had no time to investigate but it seems that since the last update the Chromecast doesn't advertise consistently over the mDNS protocol.

Usual Chromecast clients (Google Chrome, the Android Chromecast SDK) still use the old protocols for backward compatibility with some apps (SSDP for discovery and DIAL for launch / control) and the best guess currently is Chrome detects the dongles thanks to SSDP.

chromecast-scanner used to implement both methods for discovery but I see @xat changed that just a few minutes ago !

@xat how is it going ? Any news on this front ?

@xat
Copy link
Contributor

xat commented Feb 19, 2015

The SSDP module brought in too much node-gyp trouble, thats why I got rid of it.
There was also an MDNS Problem related to node v0.12.x. You can read about it here: mdns-js/node-mdns-js#31

I've temporary worked around the MDNS problem so chromecast-scanner now finds chromecast in the network ( at least for me :-D )

@rknell
Copy link

rknell commented Feb 22, 2015

Hi xat,

probably not the right place, but I'm here now!

The new version you pushed up (0.4.1) almost immediately returns device not found for me. I'm going to try and roll my own solution using SSDP, besides the node-gyp, was there anything else that was of concern?

@xat
Copy link
Contributor

xat commented Feb 22, 2015

@rknell which node version are you using?

node-gyp was the only problem with SSDP I know of.

@rknell
Copy link

rknell commented Feb 22, 2015

Hi,
Its v0.10.35

Just used the code you posted over here (below):
#22

And it worked immediately. Also tried rolling my own mDNS implementation and had no luck there either.

var Client = require('node-ssdp').Client
var client = new Client();

client.on('response', function (headers, statusCode, rinfo) {
  console.log('chromecast running on address', rinfo.address);
  client._stop();
});

client.search('urn:dial-multiscreen-org:service:dial:1');

@xat
Copy link
Contributor

xat commented Feb 22, 2015

works fine for me with v0.10.35 (there is a known issue on v0.11.13 and bigger, see mafintosh/multicast-dns#2). What Chromecast firmware version are you on?

@thibauts thibauts closed this as completed Apr 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants