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

Mosquitto Will Not Bind to Both IPv4 and IPv6 for Websockets. #2628

Open
arshamahmadi opened this issue Sep 7, 2022 · 2 comments
Open

Mosquitto Will Not Bind to Both IPv4 and IPv6 for Websockets. #2628

arshamahmadi opened this issue Sep 7, 2022 · 2 comments

Comments

@arshamahmadi
Copy link

arshamahmadi commented Sep 7, 2022

Hi, there is a similar issue reported under #1974 but it's marked as "resolved" by the bot. I believe this hasn't been resolved yet. Adding socket_domain ipv4 to /etc/mosquitto/conf.d/default.conf will only switch from IPv6 to IPv4 but how can one have Mosquitto bind to both IPv4 and IPv6 after enabling protocol websockets just like how protocol mqtt can bind to both IPv4 and IPv6 without any additional directives?

I can reproduce this in Mosquitto version 2.0.11 running on Ubuntu 22.04.1 LTS. I used 41180 for Websocket and 41183 for MQTT protocol. Here's the netstat output before adding the socket_domain ipv4 directive:

# netstat -tunlp | grep LISTEN
tcp        0      0 0.0.0.0:41183           0.0.0.0:*               LISTEN      455777/mosquitto
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      546/systemd-resolve
tcp6       0      0 :::41180                :::*                    LISTEN      455777/mosquitto
tcp6       0      0 :::41183                :::*                    LISTEN      455777/mosquitto

Here it is after adding the socket_domain ipv4 directive and restarting the service:

# netstat -tunlp | grep LISTEN
tcp        0      0 0.0.0.0:41180           0.0.0.0:*               LISTEN      455670/mosquitto
tcp        0      0 0.0.0.0:41183           0.0.0.0:*               LISTEN      455670/mosquitto
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      546/systemd-resolve
tcp6       0      0 :::41183                :::*                    LISTEN      455670/mosquitto

Thanks in advance for your help.

@ralight
Copy link
Contributor

ralight commented Apr 8, 2023

I believe it depends on how libwebsockets is compiled. It does not have support for IPv6 compiled in by default.

@cateee
Copy link

cateee commented Feb 7, 2024

@ralight : no. In my case, but also in the original problem, the IPv6 web-socket is selected by default, only with explicit configuration socket_domain ipv4 we see it as IPv4. Duplicating the listener changing the socket_domains is not working (configuration error), but if I select a different port, I can get both IPv4 and IPv6 websockets. Note TCP MQTT has not such problem: by default it opens both protocols.

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

3 participants