On 07/08/2019 22:35, Anil Gupta wrote:
    
    
    Anil
    
    
    Thanks for the response, but this
      doesn't really solve the issues I raised.
    
    
      
      
      
      
        Hello Peter,
         
        It is my understanding that a listener is
          associated with a port.
        
       
    
    OK. My understanding is that a listener is associated with a socket
    bound to an IP address and port. Presumably, each listener is a
    unique socket instance.
    
      
         
        I think that you are trying to assign port
          1883 to local and internet connections Which is why you are
          getting the error on daemon startup.
       
    
    AFAIU, each interface will have its own separate port 1883?
    
      
         
        There are a couple of ways to address the
          issue.
        
          - Use
            different ports and ip address (listener / port combo) for
            internet and local
            - Listener
              1883 ipaddr/localhost
- Listener
              1885 ipaddr/internet facing
- Use default
            port 1883 with no IP Address (listener) which will allow
            internet and local  devices to connect
- If there is
            a firewall / router facing the internet, setup a forwarding
            rule to redirect internet devices to come on 1883 but port
            forwarded to second listener
 
    
    I have turned off the firewall with no effect, so I infer this is
    not a firewall issue.
    To further explain my situation:
    I have a Linux machine with three interfaces:
    1) localhost (obviously)
    
    2) A network card statically mapped to 192.168.0.1, which is
      connected to  wireless access point.
    3) A second network card with a DHCP-leased IP address and
      connected to the public internet.
    I want to listen on (1) and (2) for MQTT traffic, but I do not
      want to listen for *any* MQTT traffic on (3).
    My mosquitto configuration file (/etc/mosquitto/mosquitto.conf)
      is the default installed version. On top of this, I have a local
      config file in /etc/mosquitto/conf.d that contains the following:
    allow_anonymous false 
    connection_messages true 
    log_dest syslog 
    log_type error 
    log_type warning 
    password_file /etc/mosquitto/passwd 
    socket_domain ipv4
    'A'
    where 'A' is some set of directives to configure the listeners. I
      have tried the following:
    port 1883 
    bind_interface localhost 
    This works fine as verified with mosquitto_sub/pub, plus 'netstat
      -tlpn' lists an LISTEN port associated with the mosquitto process.
    
    From my reading of the docs  & what I *want* to achieve, I
      would have thought that the following should work for me:
    
    listener 1883 localhost 
    listener 1883 192.168.0.1 
    but it does not! Testing with mosquitto_sub reports "Connection
      refused", the log shows the "Error: Address already in use" message  on
          service startup, and netstat lists zero LISTEN ports
          associated with mosquitto. FWIW, the following combinations
          (tried individually!):
        
    
    port 1883
    bind_interface localhost 
    listener 1883 192.168.0.1 
    
    
    listener 1883 
    
    
    listener 1883 localhost 
    listener 1885 192.168.0.1 
    
    
    all give exactly the same outcome. Note the last variant using
      different port numbers was suggested by Anil... but same outcome.
    
    So. Any suggestions on what I am doing wrong here? Or what
      fundamental point I have misunderstood?
    
    
      
         
        Please note one you have made the changes,
          you need to stop the mosquito process and restart it. Just
          restarting the process does not help.
       
    
    OK. Given that this thread will be archived, can I point out this
    advice is not correct: 'systemctl restart' - by definition - stops
    the service before restarting it, as can evidenced by the system
    log. I think you are getting mixed up with 'reload', which does
    exhibit the behaviour you describe.
    
      
    
    ...snip
    Peter