question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Homebridge listens on tcp6 only

See original GitHub issue

Hi,

I have two HomeBridge instances running. The problematic one is on Debian:

root@supermicro:/etc# netstat -an | grep 51828 | grep LISTEN
tcp6       0      0 :::51828                :::*                    LISTEN     

It listens on IPv6 only, but is advertised with IPv4 and IPv6:

root@supermicro:/etc# avahi-browse --verbose _hap._tcp | grep Supermicro
Server version: avahi 0.6.31; Host name: Supermicro.local
E Ifce Prot Name                                          Type                 Domain
+   eth1 IPv6 Homebridge Supermicro                         _hap._tcp            local
+   eth1 IPv4 Homebridge Supermicro                         _hap._tcp            local
+   eth0 IPv6 Homebridge Supermicro                         _hap._tcp            local
+   eth0 IPv4 Homebridge Supermicro                         _hap._tcp            local

Another instance on a Mac works fine:

➜  ~ netstat -an | grep 51826  
tcp46      0      0  *.51826                *.*                    LISTEN     

This one listens on both, IPv4 and IPv6 and is advertised as such.

How can I force hombridge to use both, IPv4 and IPv6 or advertise IPv6 only?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

7reactions
fuzzy01commented, Jul 14, 2017

This the result of the way nodejs creates the server socket, see here: (homebridge / hap-nodejs creates the server socket without specifying a hostname)

https://github.com/nodejs/node/issues/9390 and here https://github.com/nodejs/node/commit/12cf3594235e6c4c6838ae7588b5e73ad9775dfa

It looks like the behaviour of nodejs on Ubuntu/Debian has changed, it opens only a tcp6 socket.

It is easy to test it, if you start a simple server:

node -e "net.createServer(c=>console.log).listen(5555)"

netstat -a | grep 5555
tcp6       0      0 [::]:5555               [::]:*                  LISTEN    

The solution is to modify hap-nodejs to create a tcp4 server socket or both.

A quick fix is to modify eventedhttp.js in /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util, in line 60:

this._tcpServer.listen(targetPort);

to this

this._tcpServer.listen(targetPort, '0.0.0.0');

2reactions
Sailing74commented, Sep 24, 2018

It just worked for me as well - thanks!

Any plans to include this into homebridge in some way?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Homebridge listens on tcp6 only · Issue #1277 - GitHub
Hi, I have two HomeBridge instances running. The problematic one is on Debian: root@supermicro:/etc# netstat -an | grep 51828 | grep LISTEN ......
Read more >
Things I did (that eventually worked!) to make my RPi3 ...
Assign static IPs to everything, at least HomeKit Hub (e.g. ATV) and RPi. Disable IPV6 on RPi, see https://github.com/nfarina/homebridge/issues/ ...
Read more >
Cannot access web admin after homebridge update - Help
Running pihole on a homebridge raspbian image. Earlier in the day updated homebridge to v1.1.7. Not sure if this affected anything, but nothing...
Read more >
Repository: Homebridge add-on - Home Assistant Community
I just released an add-on for Homebridge. The installation procedure is explained in the README. If you're familiar with both Hass.io ...
Read more >
MDNSServerOptions | @homebridge/ciao - v1.1.5
Documentation for @homebridge/ciao - v1.1.5. ... If specified, the mdns server will only listen on the specified interfaces (allowlist).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found