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

Windows: MQTT protocol connections dont work when too many websocket connections #1934

Closed
sectokia opened this issue Dec 8, 2020 · 7 comments
Milestone

Comments

@sectokia
Copy link

sectokia commented Dec 8, 2020

I have a problem with v2 on windows, where once too many websocket clients connect, the MQTT protocol listener won't accept connections anymore.

Here is a reliable procedure to reproduce:
-Connect a client via protocol MQTT.
-Connect 72 clients via protocol Websocket (I verify more than 64 at once by waiting for PINGREQ/PINGRESP, how is this possible, I thought the limit was 64?)
-Kill the client connected via MQTT, and wait for mosquitto to timeout disconnect it.
-Start any MQTT client again on MQTT protocol. All clients I've tried report a connack timeout, and there is no "New connection" ever reported in the log.
-Even if you then disconnect all 72 websocket clients, you still cannot connect via MQTT protocol anymore. Only way I've found to fix it is to restart mosquitto.

Invocation:
mosquitto -c ..\config\mosquitto.conf > ..\log\mosquitto.log
This is my conf:

###########################################
per_listener_settings true
allow_zero_length_clientid true
auto_id_prefix auto-
check_retain_source true
persistent_client_expiration 1m
retain_available true
sys_interval 10
autosave_interval 1800
autosave_on_changes false
persistence true
persistence_file mosquitto.db
log_dest stdout
log_type all
connection_messages true
log_timestamp true
log_timestamp_format %Y-%m-%dT%H:%M:%S

###########################################
listener 1883
protocol mqtt
allow_anonymous false
password_file ..\config\mosquitto.pw.conf
acl_file ..\config\mosquitto.acl.conf

##########################################
listener 8083
protocol websockets
allow_anonymous false
password_file ..\config\mosquitto.pw.conf
acl_file ..\config\mosquitto.acl.conf
http_dir ..\www

@ralight
Copy link
Contributor

ralight commented Dec 8, 2020

The 64 client limit must no longer apply due to changes in libwebsockets.

I'll try and see if I can reproduce your problem in Windows.

@sectokia
Copy link
Author

sectokia commented Dec 9, 2020

I have tried on more windows systems, and found several where once any websocket is connected, mqtt doesn't work at all?
Maybe I am doing something fundamentally wrong.

Here is my simple setup, Windows10 with mosquitto-2.0.0-install-windows-x64.exe installed.

mosquitto.conf is:

listener 1883
protocol mqtt
allow_anonymous true

listener 8083
protocol websockets
allow_anonymous true

run mosquitto:
mosquitto -c mosquitto.conf -v

output shows:

1607511019: mosquitto version 2.0.0 starting
1607511019: Config loaded from mosquitto.conf.
1607511019: Opening ipv6 listen socket on port 1883.
1607511019: Opening ipv4 listen socket on port 1883.
1607511019: Opening websockets listen socket on port 8083.
1607511019: mosquitto version 2.0.0 running

publish works as expected:
mosquitto_pub -t test -m hello
output is:

1607511044: New connection from ::1:52150 on port 1883.
1607511044: New client connected from ::1:52150 as auto-8B60F39F-504D-7C75-DEDC-B5A7B34F58AB (p2, c1, k60).
1607511044: No will message specified.
1607511044: Sending CONNACK to auto-8B60F39F-504D-7C75-DEDC-B5A7B34F58AB (0, 0)
1607511044: Received PUBLISH from auto-8B60F39F-504D-7C75-DEDC-B5A7B34F58AB (d0, q0, r0, m0, 'test', ... (5 bytes))
1607511044: Received DISCONNECT from auto-8B60F39F-504D-7C75-DEDC-B5A7B34F58AB
1607511044: Client auto-8B60F39F-504D-7C75-DEDC-B5A7B34F58AB disconnected.

now connect websocket (I'd did it via mqttjs) and subscribe to topic 'test'
Works as expected:

1607511089: New client connected from 127.0.0.1:52170 as mqttjs_a68fd89c (p2, c1, k60).
1607511089: No will message specified.
1607511089: Sending CONNACK to mqttjs_a68fd89c (0, 0)
1607511089: Received SUBSCRIBE from mqttjs_a68fd89c
1607511089:     test (QoS 0)
1607511089: mqttjs_a68fd89c 0 test
1607511089: Sending SUBACK to mqttjs_a68fd89c

now try and publish again on mqtt:

mosquitto_pub -t test -m hello -d
Client (null) sending CONNECT

Nothing happens.... after a long time mosquitto_pub outputs:
Error: Unknown error.

If you disconnect the websocket before that error, the publish suddenly works.

Repeat exact same procedure with version 1.6.9 - everything works fine - publish is able to work even when a websocket is connected.

@ralight
Copy link
Contributor

ralight commented Dec 9, 2020

I believe this is now fixed, it will be part of 2.0.1.

@ralight ralight modified the milestones: 2.0, 2.0.1 Dec 9, 2020
@sectokia
Copy link
Author

Thank you, when would 2.0.1 likely come out?
This effects both windows versions of 2.0.0
So on windows right now you can only use mosquitto 2.0.0 with one protocol

@jarapa9
Copy link

jarapa9 commented Dec 11, 2020

@sectokia was the issue resolved for you? For me the upgrade to Windows version 2.0.2 did not resolve those symptoms.

@ralight ralight reopened this Dec 11, 2020
@sectokia
Copy link
Author

Is anyone able to write a breif tutorial of how to setup to compile moqusitto for windows?

I know C, but I have no idea how to get the toolchain going to compile. On linux its so simple and I'm able to run and debug fine.

On windows however I have no idea what I am doing. I installed visual studio and opened the source code folder in visual studio, which did trigger cmake to do... something. But I have no idea where to go from there.

Anyone know how to: make a 'project' for so you can just hit compile/run/debug etc?
Install OpenSSL and Libwebsockets form source as well?

@sectokia
Copy link
Author

This issue still occurs as of 2.0.3a.

Is there any instructions for how to compile on windows anywhere?

fAuernigg pushed a commit to fAuernigg/mosquitto that referenced this issue Jan 4, 2021
fAuernigg pushed a commit to fAuernigg/mosquitto that referenced this issue Jan 4, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants