@@ -66,8 +66,9 @@ mqtt_init() ->
66
66
67
67
start_tcp_listener (TCPConf0 , CowboyOpts ) ->
68
68
{TCPConf , IpStr , Port } = get_tcp_conf (TCPConf0 ),
69
+ MaxConnections = get_max_connections (),
69
70
case ranch :start_listener (web_mqtt , get_env (num_tcp_acceptors , 10 ),
70
- ranch_tcp , TCPConf ,
71
+ ranch_tcp , [{ max_connections , MaxConnections }| TCPConf ] ,
71
72
rabbit_web_mqtt_connection_sup , CowboyOpts ) of
72
73
{ok , _ } -> ok ;
73
74
{error , {already_started , _ }} -> ok ;
@@ -85,11 +86,12 @@ start_tcp_listener(TCPConf0, CowboyOpts) ->
85
86
start_tls_listener (TLSConf0 , CowboyOpts ) ->
86
87
rabbit_networking :ensure_ssl (),
87
88
{TLSConf , TLSIpStr , TLSPort } = get_tls_conf (TLSConf0 ),
89
+ MaxConnections = get_max_connections (),
88
90
{ok , _ } = ranch :start_listener (web_mqtt_secure , get_env (num_ssl_acceptors , 10 ),
89
- ranch_ssl , TLSConf ,
91
+ ranch_ssl , [{ max_connections , MaxConnections }| TLSConf ] ,
90
92
rabbit_web_mqtt_connection_sup , CowboyOpts ),
91
93
case ranch :start_listener (web_mqtt_secure , get_env (num_ssl_acceptors , 10 ),
92
- ranch_ssl , TLSConf ,
94
+ ranch_ssl , [{ max_connections , MaxConnections }| TLSConf ] ,
93
95
rabbit_web_mqtt_connection_sup , CowboyOpts ) of
94
96
{ok , _ } -> ok ;
95
97
{error , {already_started , _ }} -> ok ;
@@ -113,19 +115,15 @@ listener_started(Protocol, Listener) ->
113
115
ok .
114
116
115
117
get_tcp_conf (TCPConf0 ) ->
116
- TCPConf1 = [{connection_type , supervisor },
117
- % % see rabbitmq/rabbitmq-web-mqtt#28 for background
118
- {max_connections , infinity }] ++ TCPConf0 ,
118
+ TCPConf1 = [{connection_type , supervisor }|TCPConf0 ],
119
119
TCPConf2 = case proplists :get_value (port , TCPConf1 ) of
120
120
undefined -> [{port , 15675 }|TCPConf1 ];
121
121
_ -> TCPConf1
122
122
end ,
123
123
get_ip_port (TCPConf2 ).
124
124
125
125
get_tls_conf (TLSConf0 ) ->
126
- TLSConf1 = [{connection_type , supervisor },
127
- % % see rabbitmq/rabbitmq-web-mqtt#28 for background
128
- {max_connections , infinity }] ++ TLSConf0 ,
126
+ TLSConf1 = [{connection_type , supervisor }|TLSConf0 ],
129
127
TLSConf2 = case proplists :get_value (port , TLSConf1 ) of
130
128
undefined -> [{port , 15675 }|proplists :delete (port , TLSConf1 )];
131
129
_ -> TLSConf1
@@ -145,5 +143,8 @@ normalize_ip(IpStr) when is_list(IpStr) ->
145
143
normalize_ip (Ip ) ->
146
144
Ip .
147
145
146
+ get_max_connections () ->
147
+ get_env (max_connections , infinity ).
148
+
148
149
get_env (Key , Default ) ->
149
150
rabbit_misc :get_env (rabbitmq_web_mqtt , Key , Default ).
0 commit comments