home-assistant/core

Sonos Integration only listens on one interface for Port 1400

nyko99 opened this issue · 2 comments

nyko99 commented

The problem

Sonos integration only listens to specific interface for port 1400

Output of Netstat executed inside homeassistant container when reloading integration

037d91a417df:/config# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:8123            0.0.0.0:*               LISTEN      67/python3          
tcp        0      0 172.26.0.2:1400         0.0.0.0:*               LISTEN      67/python3          
tcp        0      0 0.0.0.0:2001            0.0.0.0:*               LISTEN      67/python3          
tcp        0      0 127.0.0.11:37473        0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::8123                 :::*                    LISTEN      67/python3          
udp        0      0 0.0.0.0:33436           0.0.0.0:*                           67/python3          
udp        0      0 172.22.0.7:5353         0.0.0.0:*                           67/python3          
udp        0      0 172.26.0.2:5353  

I would expect that it would listen 0.0.0.0:1400 in the same way as homeassistant webui or listening to both interfaces like :5353 (mdns?) and :2001 from homematic integration. In my case i would need it to listen to 172.22.0.7:1400

This causes the integration to fallback to polling and closing the port 1400.

Im using docker in bridge mode with 2 networks only exposing ports from the proxy network 172.22.0.7 via traefik reverse proxy.
The system network interface configuration does not have an effect on this and the interface_addr config option is also showing no effect and deprecated.

What version of Home Assistant Core has the issue?

core-2024.10.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Sonos

Link to integration documentation on our website

https://www.home-assistant.io/integrations/sonos/

Diagnostics information

No response

Example YAML snippet

sonos:
  media_player:
    hosts:
      - 192.168.178.62
    advertise_addr: 192.168.178.206

Anything in the logs that might be useful for us?

No response

Additional information

No response

Hey there @jjlawren, @PeteRager, mind taking a look at this issue as it has been labeled with an integration (sonos) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of sonos can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign sonos Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


sonos documentation
sonos source
(message by IssueLinks)

The advertise address should be the address on the LAN routable from the Sonos speakers.

If you map port 1400 from the container into the host then this should work.

services:
  ha:
    container_name: ha
    image: homeassistant/home-assistant:${HA_VERSION}
    volumes:
      - ${DOCKER_FOLDER}/${HA_FOLDER}/config:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    environment:
      PROXY_IP: ${SUBNET}.1
      TZ: America/New_York
    networks: 
      local_network:
        ipv4_address: ${SUBNET}.2
    depends_on:        
      - zwave
      - mariadb
    ports:
      - 8123:8123
      - 1400:1400
      - 1401:1401

I do agree it should listen on 0.0.0.0 that is a change to the SoCo library https://github.com/SoCo/SoCo

You should be able to configure a port forwarding rule from host to the port that is bound. You also may be able to get it to bind to the other address by reversing your network declarations in the compose file.