emqx / emqx

The most scalable open-source MQTT broker for IoT, IIoT, and connected vehicles
https://www.emqx.com/
Other
14.07k stars 2.24k forks source link

Cannot add a second MQTT-WS TCP Port #3178

Closed communig8-public closed 4 years ago

communig8-public commented 4 years ago

Environment

Description

Added a second mqtt-ws port to the configuration results in the first port marked as "already_started".

Additional configuration for second port, added at end of file;

      listener.ws.external2.zone = external
      listener.ws.external2 = 8085
      listener.ws.external2.mqtt_path = /mqtt
      listener.ws.external2.acceptors = 4
      listener.ws.external2.max_connections = 102400
      listener.ws.external2.max_conn_rate = 1000
      listener.ws.external2.access.1 = allow all
      listener.ws.external2.verify_protocol_header = on
      listener.ws.external2.backlog = 1024
      listener.ws.external2.send_timeout = 15s
      listener.ws.external2.send_timeout_close = on
      listener.ws.external2.nodelay = true

Startup messages;

===== ===== LOGGING STARTED Mon Jan 13 16:37:35 GMT 2020

Exec: /usr/lib/emqx/erts-10.5.2/bin/erlexec -boot /usr/lib/emqx/releases/v4.0.0/emqx -mode embedded -boot_var ERTS_LIB_DIR /usr/lib/emqx/erts-10.5.2/../lib -mnesia dir "/var/lib/emqx/mnesia/cluster-1@172.31.18.206" -config /var/lib/emqx/configs/app.2020.01.13.16.37.35.config -args_file /var/lib/emqx/configs/vm.2020.01.13.16.37.35.args -vm_args /var/lib/emqx/configs/vm.2020.01.13.16.37.35.args -start_epmd false -epmd_module ekka_epmd -proto_dist ekka -- console^M Root: /usr/lib/emqx^M /usr/lib/emqx^M Starting emqx on node cluster-1@172.31.18.206^M Start http:management listener on 8081 successfully.^M Start http:dashboard listener on 18083 successfully.^M Start mqtt:tcp listener on 0.0.0.0:1884 successfully.^M Start mqtt:tcp listener on 127.0.0.1:11883 successfully.^M Start mqtt:tcp listener on 0.0.0.0:1883 successfully.^M Start mqtt:ws listener on 0.0.0.0:8085 successfully.^M Failed to start mqtt:ws listener on 0.0.0.0:8083 - {already_started,^M <0.1617.0>}^M !Start mqtt:ssl listener on 0.0.0.0:8883 successfully.^M Start mqtt:wss listener on 0.0.0.0:8084 successfully.^M EMQ X Broker 4.0.0 is running now!^M Eshell V10.5.2 (abort with ^G)^M (cluster-1@172.31.18.206)1>

netstat -lantp output for emqx owned ports;

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:18083 0.0.0.0: LISTEN 22449/beam.smp
tcp 0 0 127.0.0.1:11883 0.0.0.0:
LISTEN 22449/beam.smp
tcp 0 0 0.0.0.0:8081 0.0.0.0: LISTEN 22449/beam.smp
tcp 0 0 0.0.0.0:8883 0.0.0.0:
LISTEN 22449/beam.smp
tcp 0 0 0.0.0.0:4371 0.0.0.0: LISTEN 22449/beam.smp
tcp 0 0 0.0.0.0:8084 0.0.0.0:
LISTEN 22449/beam.smp
tcp 0 0 0.0.0.0:8085 0.0.0.0: LISTEN 22449/beam.smp
tcp 0 0 0.0.0.0:5369 0.0.0.0:
LISTEN 22449/beam.smp
tcp 0 0 0.0.0.0:1883 0.0.0.0: LISTEN 22449/beam.smp
tcp 0 0 0.0.0.0:1884 0.0.0.0:
LISTEN 22449/beam.smp

HJianBo commented 4 years ago

Hi @communig8-public You should use a different listener name, i.g:

listener.ws2.external = 8085
...
communig8-public commented 4 years ago

But the comment in the configuration file say...

listener.ws.$name is the IP address and port that the MQTT/WebSocket

i.e. the "name" is the third part not the second?

communig8-public commented 4 years ago

If I make the change you suggested the emqx service fails to start.

[error] You've tried to set listener.ws2.external, but there is no setting with that name.

communig8-public commented 4 years ago

Hi @HJianBo Is anyone looking at this? The suggestion you made caused emqx not to start.

HJianBo commented 4 years ago

Hi, @communig8-public Your configuration is right! Sorry for misleading to you

But the previous options are not working, It should be a bug actually. I reproduced at v4.0.0.

We will fix it in the next version. Thanks for your contribution

HJianBo commented 4 years ago

Hi, @communig8-public Thanks for your contribution.

We have released it in the v4.0.1 :)