|
|
@@ -51,12 +51,12 @@ start_listener(Proto, ListenOn, Options) when Proto == ssl; Proto == tls ->
|
|
|
|
|
|
%% Start MQTT/WS listener
|
|
|
start_listener(Proto, ListenOn, Options) when Proto == http; Proto == ws ->
|
|
|
- Dispatch = cowboy_router:compile([{'_', [{"/mqtt", emqx_ws_connection, Options}]}]),
|
|
|
+ Dispatch = cowboy_router:compile([{'_', [{mqtt_path(Options), emqx_ws_connection, Options}]}]),
|
|
|
start_http_listener(fun cowboy:start_clear/3, 'mqtt:ws', ListenOn, ranch_opts(Options), Dispatch);
|
|
|
|
|
|
%% Start MQTT/WSS listener
|
|
|
start_listener(Proto, ListenOn, Options) when Proto == https; Proto == wss ->
|
|
|
- Dispatch = cowboy_router:compile([{'_', [{"/mqtt", emqx_ws_connection, Options}]}]),
|
|
|
+ Dispatch = cowboy_router:compile([{'_', [{mqtt_path(Options), emqx_ws_connection, Options}]}]),
|
|
|
start_http_listener(fun cowboy:start_tls/3, 'mqtt:wss', ListenOn, ranch_opts(Options), Dispatch).
|
|
|
|
|
|
start_mqtt_listener(Name, ListenOn, Options) ->
|
|
|
@@ -67,6 +67,9 @@ start_mqtt_listener(Name, ListenOn, Options) ->
|
|
|
start_http_listener(Start, Name, ListenOn, RanchOpts, Dispatch) ->
|
|
|
Start(Name, with_port(ListenOn, RanchOpts), #{env => #{dispatch => Dispatch}}).
|
|
|
|
|
|
+mqtt_path(Options) ->
|
|
|
+ proplists:get_value(mqtt_path, Options, "/mqtt").
|
|
|
+
|
|
|
ranch_opts(Options) ->
|
|
|
NumAcceptors = proplists:get_value(acceptors, Options, 4),
|
|
|
MaxConnections = proplists:get_value(max_connections, Options, 1024),
|