Comments (11)
from vernemq.
@DomasM Thanks. Can you try setting max_request_line_length
in vernemq.conf
?
listener.tcp.default.max_request_line_length=16500
(whatever length you might seem to need)
Set this for your named listener where you'll need it. (adapt default
to your listener name)
👉 Thank you for supporting VerneMQ: https://github.com/sponsors/vernemq
👉 Using the binary VerneMQ packages commercially (.deb/.rpm/Docker) requires a paid subscription.
from vernemq.
@ioolkos Thank you for help. I'm not sure what's my listener name, but anyway vernemq would not start with such setting, saying that it does not exist and suggesting listener.http.default.max_request_line_length, which I tried but it seems that did not change anything in actual behaviour, i.e. still 431.
vernemq | 2024-03-15T11:42:36.795012+00:00 [error] You've tried to set listener.tcp.default.max_request_line_length, but there is no setting with that name.
vernemq | 2024-03-15T11:42:36.795098+00:00 [error] Did you mean one of these?
vernemq | 2024-03-15T11:42:36.891103+00:00 [error] listener.http.$name.max_request_line_length
vernemq | 2024-03-15T11:42:36.891199+00:00 [error] listener.https.$name.max_request_line_length
vernemq | 2024-03-15T11:42:36.891270+00:00 [error] listener.tcp.$name.max_connection_lifetime
vernemq | 2024-03-15T11:42:36.893026+00:00 [error] Error generating configuration in phase transform_datatypes
vernemq | 2024-03-15T11:42:36.893124+00:00 [error] Conf file attempted to set unknown variable: listener.tcp.default.max_request_line_length
vernemq exited with code 0
from vernemq.
@DomasM Thanks a lot for testing!
The config is obviously only for HTTP listeners, sorry about that.
There's additional options for Cowboy/Ranch connections:
https://github.com/ninenines/cowboy/blob/3ea8395eb8f53a57acb5d3c00b99c70296e7cdbd/doc/src/manual/cowboy_http.asciidoc#L31
Those are currently not exposed in the vernemq.conf
file like max_request_line_length
.
A workaround is to update the max_header_value_length
option dynamically in a VerneMQ shell. (sudo vernemq attach
, when done detach with ctrl+g
and then at the user switch q
).
Example for a HTTP listener running on 127.0.0.1:8888. The listener does not have to be restarted, it is updated live:
Opts = ranch:get_protocol_options({{127,0,0,1}, 8888}).
NewOpts = maps:put(max_header_value_length, 8192, Opts).
ranch:set_protocol_options({{127,0,0,1}, 8888}, NewOpts).
You could at least use this to test whether this really is about that specific setting. The default value for max_header_value_length
is 4096.
👉 Thank you for supporting VerneMQ: https://github.com/sponsors/vernemq
👉 Using the binary VerneMQ packages commercially (.deb/.rpm/Docker) requires a paid subscription.
from vernemq.
@ioolkos Thank you again. I tried as suggested and while setting cowboy options seems to work, further requests still end with 431.
Additionally, as you can see initial max_header_value_length is 8192, while my cookie size is about 6700, so it should still pass?
https://github.com/ninenines/cowboy/blob/3ea8395eb8f53a57acb5d3c00b99c70296e7cdbd/src/cowboy_http.erl#L677
Opts = ranch:get_protocol_options({{127,0,0,1}, 8888}).
#{connection_type => supervisor,
env =>
#{dispatch =>
[{'_',[],
[{[<<"metrics">>],[],vmq_metrics_http,[]},
{[<<"api">>,<<"v1">>,'...'],[],vmq_http_mgmt_api,[]},
{[<<"status.json">>],[],vmq_status_http,[]},
{[<<"status">>],
[],cowboy_static,
{priv_file,vmq_server,"static/index.html"}},
{[<<"status">>,'...'],
[],cowboy_static,
{priv_dir,vmq_server,"static"}},
{[<<"health">>],[],vmq_health_http,[]},
{[<<"api">>,<<"v2">>,command],[],vmq_http_v2_api,[]},
{[<<"restmqtt">>,<<"api">>,<<"v1">>,<<"publish">>],
[],vmq_http_pub,
[{publish_fun,#Fun<vmq_reg.17.40855500>}]}]}]},
max_header_value_length => 8192,
opts =>
[{max_connections,10000},
{nr_of_acceptors,10},
{config_mod,vmq_http_config},
{config_fun,config},
{max_request_line_length,63000},
{http_modules,"[]"},
{listener_name,"default"},
{proxy_protocol,false}]}
([email protected])2> NewOpts = maps:put(max_header_value_length, 62999, Opts).
#{connection_type => supervisor,
env =>
#{dispatch =>
[{'_',[],
[{[<<"metrics">>],[],vmq_metrics_http,[]},
{[<<"api">>,<<"v1">>,'...'],[],vmq_http_mgmt_api,[]},
{[<<"status.json">>],[],vmq_status_http,[]},
{[<<"status">>],
[],cowboy_static,
{priv_file,vmq_server,"static/index.html"}},
{[<<"status">>,'...'],
[],cowboy_static,
{priv_dir,vmq_server,"static"}},
{[<<"health">>],[],vmq_health_http,[]},
{[<<"api">>,<<"v2">>,command],[],vmq_http_v2_api,[]},
{[<<"restmqtt">>,<<"api">>,<<"v1">>,<<"publish">>],
[],vmq_http_pub,
[{publish_fun,#Fun<vmq_reg.17.40855500>}]}]}]},
max_header_value_length => 62999,
opts =>
[{max_connections,10000},
{nr_of_acceptors,10},
{config_mod,vmq_http_config},
{config_fun,config},
{max_request_line_length,63000},
{http_modules,"[]"},
{listener_name,"default"},
{proxy_protocol,false}]}
([email protected])3> ranch:set_protocol_options({{127,0,0,1}, 8888}, NewOpts).
ok
Opts2 = ranch:get_protocol_options({{127,0,0,1}, 8888}).
#{connection_type => supervisor,
env =>
#{dispatch =>
[{'_',[],
[{[<<"metrics">>],[],vmq_metrics_http,[]},
{[<<"api">>,<<"v1">>,'...'],[],vmq_http_mgmt_api,[]},
{[<<"status.json">>],[],vmq_status_http,[]},
{[<<"status">>],
[],cowboy_static,
{priv_file,vmq_server,"static/index.html"}},
{[<<"status">>,'...'],
[],cowboy_static,
{priv_dir,vmq_server,"static"}},
{[<<"health">>],[],vmq_health_http,[]},
{[<<"api">>,<<"v2">>,command],[],vmq_http_v2_api,[]},
{[<<"restmqtt">>,<<"api">>,<<"v1">>,<<"publish">>],
[],vmq_http_pub,
[{publish_fun,#Fun<vmq_reg.17.40855500>}]}]}]},
max_header_value_length => 62999,
opts =>
[{max_connections,10000},
{nr_of_acceptors,10},
{config_mod,vmq_http_config},
{config_fun,config},
{max_request_line_length,63000},
{http_modules,"[]"},
{listener_name,"default"},
{proxy_protocol,false}]}
from vernemq.
Hm, okay. What listeners do you have running (vmq-admin listener show
), and is port 8888 really where you have that listener running?
👉 Thank you for supporting VerneMQ: https://github.com/sponsors/vernemq
👉 Using the binary VerneMQ packages commercially (.deb/.rpm/Docker) requires a paid subscription.
from vernemq.
I suppose. Tried setting cowboy options for 8080, but it complained.
Opts = ranch:get_protocol_options({{127,0,0,1}, 8080}).
** exception error: bad argument
in function ets:lookup_element/3
called as ets:lookup_element(ranch_server,{proto_opts,{{127,0,0,1},8080}},2)
*** argument 2: not a key that exists in the table
in call from ranch_server:get_protocol_options/1 (/opt/vernemq/_build/default/lib/ranch/src/ranch_server.erl, line 168)
$ vmq-admin listener show
+--------+---------+--------------+-------+------------+-----------+--------------+-----------+
| type | status | address | port | mountpoint | max_conns | active_conns | all_conns |
+--------+---------+--------------+-------+------------+-----------+--------------+-----------+
| http | running | 127.0.0.1 | 8888 | | 10000 | 0 | 0 |
+--------+---------+--------------+-------+------------+-----------+--------------+-----------+
| mqtt | running | 192.168.16.2 | 1883 | | 10000 | 4 | 4 |
+--------+---------+--------------+-------+------------+-----------+--------------+-----------+
| mqttws | running | 192.168.16.2 | 8080 | | 10000 | 0 | 0 |
+--------+---------+--------------+-------+------------+-----------+--------------+-----------+
| http | running | 192.168.16.2 | 8888 | | 10000 | 0 | 0 |
+--------+---------+--------------+-------+------------+-----------+--------------+-----------+
| vmq | running | 192.168.16.2 | 44053 | | 10000 | 0 | 0 |
+--------+---------+--------------+-------+------------+-----------+--------------+-----------+
from vernemq.
You don't have a listener {{127,0,0,1}, 8080}
, you have {{192,168,16,2}, 8080}
.
👉 Thank you for supporting VerneMQ: https://github.com/sponsors/vernemq
👉 Using the binary VerneMQ packages commercially (.deb/.rpm/Docker) requires a paid subscription.
from vernemq.
@DomasM were you able to make this work?
Do you think we should expose the max_header_value_length
in vernemq.conf
? or to re-word the question: do you think the cookie size you used here should be within a "normal" size window?
👉 Thank you for supporting VerneMQ: https://github.com/sponsors/vernemq
👉 Using the binary VerneMQ packages commercially (.deb/.rpm/Docker) requires a paid subscription.
from vernemq.
@ioolkos I finally got it working by setting max_header_value_length for the correct listener. IP address of the listener changes from run to run, so the steps current solution is:
- Modify vernemq.conf file with listener.http.default.max_request_line_length=63000
- Run vernemq
- Run
vmq-admin listener show
and notice which ip address and port is used for mqttws listener - Set options for cowboy/ranch with these IP address and port values.
Address = {192,168,32,2}.
Port = 8080.
Opts = ranch:get_protocol_options({Address, Port}).
NewOpts = maps:put(max_header_value_length, 62999, Opts).
ranch:set_protocol_options({Address, Port}, NewOpts).
To have this working more properly maybe some copy-paste from #2161 would be enough to map max_header_value_length property too?
from vernemq.
@DomasM yes, same approach. In addition, we'd likely need to grab and apply the setting in vmq_ranch_config
module where we set the protocol_opts.
👉 Thank you for supporting VerneMQ: https://github.com/sponsors/vernemq
👉 Using the binary VerneMQ packages commercially (.deb/.rpm/Docker) requires a paid subscription.
from vernemq.
Related Issues (20)
- [Bug]: vmq_http_pub plugins apis not restricted by api key and bounded to default http listener HOT 7
- Enhancement: MQTT TLS listeners with multiple TLS versions.
- [Bug]: Loss of retained QoS 1 messages across cluster nodes HOT 1
- [Bug]: <title>HIGH CPU for VerneMQ (beam.smp) HOT 3
- Support Alternative TCP listener with proxy protocol enabled by default HOT 6
- VerneMQ HTTPs support HOT 12
- [Bug]: CRASH REPORT Process with 0 neighbours crashed with reason: bad argument in vmq_cluster_com:process_bytes/3 line 171 HOT 1
- Seeing various messages in the logs when under load HOT 3
- [Bug]: VerneMQ Certificates for testing expired HOT 1
- vernemq-1.13.0.bullseye.arm64.tar.gz support Ubuntu aarch64? HOT 7
- [Bug]: SSL Validation Error with Diversity - Postgresql starting 2.0.0 HOT 18
- [Bug]: Some protocol violations or bugs in VerneMQ HOT 19
- Log format "JSON" also for Console Logging HOT 3
- 500 server error in publish response (vmq_http_pub) HOT 4
- Drop OTP24, add OTP27 support HOT 3
- [Bug]: Node failure causes cluster restart HOT 7
- MQTT Client Authentication getting failed due to plugin_chain_exhausted HOT 3
- [Bug]: plugins.vmq_webhooks is on but not triggering HTTP endpoint HOT 2
- [Bug]: Error on cluster startup HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vernemq.