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

parsing multicast-dns responses results in unreachable device #32

Open
catdad opened this issue Jun 1, 2018 · 2 comments
Open

parsing multicast-dns responses results in unreachable device #32

catdad opened this issue Jun 1, 2018 · 2 comments

Comments

@catdad
Copy link
Contributor

catdad commented Jun 1, 2018

When I use this module, I get an ETIMEDOUT error connecting to a strange IP address 198.105.244.228. The real IP of my chromecast on my network, however, is 192.168.1.105. I did a bit of investigation and found that the host which is parsed from the multicast-dns results is 072d136d-9716-69e2-2758-36bf56482f43.local, and when I do a dns.lookup() on it, sure enough, it resolves to that strange IP address.

Looking a bit further, I saw what appears to be the issue in the multicast-dns responses. On my network, the answers and additionals that I get are these:

answers: [
  {
    "name": "_googlezone._tcp.local",
    "type": "PTR",
    "class": 1,
    "ttl": 120,
    "flush": false,
    "data": "3e0de4d2-1dc6-b2b9-e93d-d3eadf2a301a._googlezone._tcp.local"
  }
]


additionals: [
  {
    "name": "Chromecast-072d136d971669e2275836bf56482f43._googlecast._tcp.local",
    "type": "TXT",
    "class": 1,
    "ttl": 4500,
    "flush": true,
    "data": {
      "type": "Buffer",
      "data": [
        35,
        61
      ]
    }
  },
  {
    "name": "Chromecast-072d136d971669e2275836bf56482f43._googlecast._tcp.local",
    "type": "SRV",
    "class": 1,
    "ttl": 120,
    "flush": true,
    "data": {
      "priority": 0,
      "weight": 0,
      "port": 8009,
      "target": "072d136d-9716-69e2-2758-36bf56482f43.local"
    }
  },
  {
    "name": "072d136d-9716-69e2-2758-36bf56482f43.local",
    "type": "A",
    "class": 1,
    "ttl": 120,
    "flush": true,
    "data": "192.168.1.105"
  }
]

Looks like there is an A type additional that has the correct IP address. However, this additional is never even looked at. The SRV additional which is used has data.target strange address which resolves to the strange IP.

When I overload the player.host with the correct IP, the module works well and can cast media. However, since the A additional uses different name than the one in the rest of the additionals (and the one used to store cast devices), I am not totally sure how to fix it, since I don't know what other dns responses look like (since I assume this works well on other people's networks).

@catdad
Copy link
Contributor Author

catdad commented Jun 1, 2018

I added this code, which seems to make it work for me:

  if (a.type === 'A') {
    var aName = name.replace('.local', '');
    Object.keys(casts).forEach(function (castName) {
      if (castName.indexOf(aName) > -1) {
        casts[castName].host = a.data;
      }
    });
  }

@gabrielgradinaru
Copy link

I have also encountered this issue.
On my network, the answers and additionals that I get are these:

  answers:
   [ { name: '_googlecast._tcp.local',
       type: 'PTR',
       class: 1,
       ttl: 120,
       flush: false,
       data:
        'Chromecast-d14c04a52f93df9565bdc21ac6000132._googlecast._tcp.local' } ],
  additionals:
   [ { name:
        'Chromecast-d14c04a52f93df9565bdc21ac6000132._googlecast._tcp.local',
       type: 'TXT',
       class: 1,
       ttl: 4500,
       flush: true,
       data:
        <Buffer 23 69 64 3d 64 31 34 63 30 34 61 35 32 66 39 33 64 66 39 35 36 35 62 64 63 32 31 61 63 36 30 30 30 31 33 32 23 63 64 3d 32 36 32 34 41 36 38 32 35 45 ... > },
     { name:
        'Chromecast-d14c04a52f93df9565bdc21ac6000132._googlecast._tcp.local',
       type: 'SRV',
       class: 1,
       ttl: 120,
       flush: true,
       data: [Object] },
     { name: 'd14c04a5-2f93-df95-65bd-c21ac6000132.local',
       type: 'A',
       class: 1,
       ttl: 120,
       flush: true,
       data: '192.168.1.129' } ] }

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

2 participants