Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] Bind Address For Websockets

Hi Chris,

Yes, you're right it's because libwebsockets only supports binding to
an interface, not an ip address.Your idea of a interface option for
websockets listeners is ok. If you'd like to submit a patch for it
I'll take a look.

Cheers,

Roger




On Wed, Sep 2, 2015 at 9:43 PM, Chris . <chris_flcpc@xxxxxxxxxxx> wrote:
> OK, so I'm guessing this is never going to work for mosquitto websockets at
> the moment because of libwebsockets.
>
> I've had a browse through the following and note that IP addresses are
> suspicious by their absence in libwebsockets as the latter seems to use
> interfaces instead:
>
> mosq_websockets_init()
> libwebsocket_create_context()
> lws_context_init_server() -> in fact does an explicit
> "serv_addr4.sin_addr.s_addr = INADDR_ANY" by default
>
>
> It would be nice, maybe, if mosquitto.conf and mosq_websockets_init
> ()supported the use of an "iface" parameter for websockets on the listener
> line, so I could specify the loopback or a virtual to force my bind address
> as I wished.
>
>
> Many thanks for the great software & keep up the good work,
> Chris.
>
> ________________________________
>
> Hi,
>
> I am running mosquitto version 1.4.3 (build date Wed, 19 Aug 2015 12:10:03
> +0100) and am having trouble getting mosquitto to bind to specific IP
> addresses for websockets connections. It seems to work fine for 1883 & 8883.
> Am I missing something ?
>
> Here is my config:
>
> # CAN bind port 1883 to any address
> listener 1883 127.0.0.1
> protocol mqtt
>
> # CAN bind port 8883 to any address
> listener 8883 127.0.0.1
> ##listener 8883
> cafile /etc/mosquitto/ca_certificates/server-cafile.pem
> certfile /etc/mosquitto/certs/server-certificate.pem
> keyfile /etc/mosquitto/certs/server-private-key.pem
>
> # CANNOT bind port 8080 to any address - it binds to 0.0.0.0
> listener 8080 127.0.0.1
> protocol websockets
>
> # CANNOT bind port 8081 to any address - It binds to 0.0.0.0
> listener 8081 127.0.0.1
> protocol websockets
> cafile /etc/mosquitto/ca_certificates/server-cafile.pem
> certfile /etc/mosquitto/certs/server-certificate.pem
> keyfile /etc/mosquitto/certs/server-private-key.pem
>
> With the following results:
>
> # uname -a
> Linux iotgroup-07818742 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00
> UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
>
> # netstat -an | grep -i LIST
> tcp        0      0 127.0.0.1:1883          0.0.0.0:*               LISTEN
> tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN
> tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN
> tcp        0      0 127.0.0.1:8883          0.0.0.0:*               LISTEN
>
>
> No obvious error messages:
>
> 1441046179: Opening ipv4 listen socket on port 1883.
> 1441046179: Opening ipv4 listen socket on port 8883.
> 1441046179: Opening websockets listen socket on port 8080.
> 1441046179: Opening websockets listen socket on port 8081.
> 1441046193: mosquitto version 1.4.3 terminating
> 1441046193: mosquitto version 1.4.3 (build date Wed, 19 Aug 2015 12:10:03
> +0100) starting
>
>
> Any help greatly appreciated.
> Many thanks,
> Chris.
>
> _______________________________________________
> mosquitto-dev mailing list
> mosquitto-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/mosquitto-dev


Back to the top