#### Environment
- OS: Linux dd 4.15.0-1036-gcp #38-Ubuntu SMP Mon Jun 24 13:…49:05 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
- Erlang/OTP:
- EMQ: v3.1.1
#### Description
Hello.
I'm trying to send and receive a lot of json payloads from different topics with Python using this library: https://github.com/astrorafael/twisted-mqtt
On my Ubuntu 18.04.2 server installed broker, which handles all the messages from this library.
The JSON response contains a lot of information, up to 1 MB. And when my script is running, it sometimes display the message
`Failure: twisted.internet.error.ConnectionDone: Connection was closed cleanly`
Then I have looked upon the logs in the server (erlang.log.4). Here they are:
```
=====
===== LOGGING STARTED Mon Aug 12 14:42:00 UTC 2019
=====
Exec: /usr/lib/emqx/erts-10.2/bin/erlexec -boot /usr/lib/emqx/releases/3.1.1/emqx -mode embedded -boot_var ERTS_LIB_DIR /usr/lib/emqx/erts-10.2/../lib -mnesia dir "/var/lib/emqx/mnesia/emqx@127.0.0.1" -config /var/lib/emqx/configs/app.2019.08.12.14.42.01.config -args_file /var/lib/emqx/configs/vm.2019.08.12.14.42.01.args -vm_args /var/lib/emqx/configs/vm.2019.08.12.14.42.01.args -- console
Root: /usr/lib/emqx
/usr/lib/emqx
Starting emqx on node emqx@127.0.0.1
Start http:management listener on 8080 successfully.
Start http:dashboard listener on 18083 successfully.
Start mqtt:tcp listener on 127.0.0.1:11883 successfully.
Start mqtt:tcp listener on 0.0.0.0:1883 successfully.
Start mqtt:ws listener on 0.0.0.0:8083 successfully.
Start mqtt:ssl listener on 0.0.0.0:8883 successfully.
Start mqtt:wss listener on 0.0.0.0:8084 successfully.
EMQ X Broker v3.1.1 is running now!
Eshell V10.2 (abort with ^G)
(emqx@127.0.0.1)1> 2019-08-12 14:44:20.098 [error] orderbook_summrizer@91.102.178.89:48094 [Connection] Shutdown exceptionally due to message_queue_too_long
(emqx@127.0.0.1)1> 2019-08-12 14:44:41.403 [error] orderbook_summrizer@91.102.178.89:48130 [Connection] Shutdown exceptionally due to message_queue_too_long
(emqx@127.0.0.1)1> 2019-08-12 14:45:10.050 [error] orderbook_summrizer@91.102.178.89:48174 [Connection] Shutdown exceptionally due to message_queue_too_long
(emqx@127.0.0.1)1> 2019-08-12 14:49:41.711 [error] [Pool] Error: badarg, [{ets,lookup,[emqx_submon,<0.1742.0>],[]},
{emqx_broker_helper,clean_down,1,
[{file,"src/emqx_broker_helper.erl"},{line,148}]},
{lists,foreach,2,[{file,"lists.erl"},{line,1338}]},
{emqx_pool,handle_cast,2,
[{file,"src/emqx_pool.erl"},{line,104}]},
{gen_server,try_dispatch,4,
[{file,"gen_server.erl"},{line,637}]},
{gen_server,handle_msg,6,
[{file,"gen_server.erl"},{line,711}]},
{proc_lib,wake_up,3,
[{file,"proc_lib.erl"},{line,259}]}]
(emqx@127.0.0.1)1> Stop mqtt:tcp listener on 127.0.0.1:11883 successfully.
(emqx@127.0.0.1)1> Stop mqtt:tcp listener on 0.0.0.0:1883 successfully.
(emqx@127.0.0.1)1> Stop mqtt:ws listener on 0.0.0.0:8083 successfully.
(emqx@127.0.0.1)1> Stop mqtt:ssl listener on 0.0.0.0:8883 successfully.
(emqx@127.0.0.1)1> Stop mqtt:wss listener on 0.0.0.0:8084 successfully.
(emqx@127.0.0.1)1> [os_mon] memory supervisor port (memsup): Erlang has closed
[os_mon] cpu supervisor port (cpu_sup): Erlang has closed
2019-08-12 14:49:41.769 [error] [Broker] Publish error: badarg
{message,<<0,5,143,236,162,80,40,121,244,66,0,0,5,87,0,5>>,
0,emqx_alarm_handler,
#{dup => false,sys => true},
#{'Content-Type' => <<"application/json">>},
<<"$SYS/brokers/emqx@127.0.0.1/alarms/system_memory_high_watermark/clear">>,
<<>>,
{1565,621381,769342}}
[{ets,lookup,[emqx_hooks,'message.publish'],[]},
{emqx_hooks,lookup,1,[{file,"src/emqx_hooks.erl"},{line,160}]},
{emqx_hooks,run_fold,3,[{file,"src/emqx_hooks.erl"},{line,112}]},
{emqx_broker,publish,1,[{file,"src/emqx_broker.erl"},{line,196}]},
{emqx_broker,safe_publish,1,[{file,"src/emqx_broker.erl"},{line,209}]},
{emqx_alarm_handler,handle_event,2,
[{file,"src/emqx_alarm_handler.erl"},{line,107}]},
{gen_event,server_update,4,[{file,"gen_event.erl"},{line,577}]},
{gen_event,server_notify,4,[{file,"gen_event.erl"},{line,559}]}]
(emqx@127.0.0.1)1> 2019-08-12 14:49:41.775 [error] ** gen_event handler emqx_alarm_handler crashed.
** Was installed in alarm_handler
** Last event was: {clear_alarm,system_memory_high_watermark}
** When handler state == []
** Reason == {aborted,{node_not_running,'emqx@127.0.0.1'}}
(emqx@127.0.0.1)1>
=====
===== LOGGING STARTED Mon Aug 12 14:50:06 UTC 2019
=====
Exec: /usr/lib/emqx/erts-10.2/bin/erlexec -boot /usr/lib/emqx/releases/3.1.1/emqx -mode embedded -boot_var ERTS_LIB_DIR /usr/lib/emqx/erts-10.2/../lib -mnesia dir "/var/lib/emqx/mnesia/emqx@127.0.0.1" -config /var/lib/emqx/configs/app.2019.08.12.14.50.07.config -args_file /var/lib/emqx/configs/vm.2019.08.12.14.50.07.args -vm_args /var/lib/emqx/configs/vm.2019.08.12.14.50.07.args -- console
Root: /usr/lib/emqx
/usr/lib/emqx
Starting emqx on node emqx@127.0.0.1
Start http:management listener on 8080 successfully.
Start http:dashboard listener on 18083 successfully.
Start mqtt:tcp listener on 127.0.0.1:11883 successfully.
Start mqtt:tcp listener on 0.0.0.0:1883 successfully.
Start mqtt:ws listener on 0.0.0.0:8083 successfully.
Start mqtt:ssl listener on 0.0.0.0:8883 successfully.
Start mqtt:wss listener on 0.0.0.0:8084 successfully.
EMQ X Broker v3.1.1 is running now!
Eshell V10.2 (abort with ^G)
(emqx@127.0.0.1)1> 2019-08-12 14:50:58.962 [error] orderbook_summrizer@91.102.178.89:48868 [Connection] Shutdown exceptionally due to message_queue_too_long
(emqx@127.0.0.1)1>
```
And the emqx.log.1 is following:
```
===== ALIVE Mon Aug 12 09:35:49 UTC 2019
===== ALIVE Mon Aug 12 09:50:49 UTC 2019
===== ALIVE Mon Aug 12 10:05:49 UTC 2019
===== ALIVE Mon Aug 12 10:20:49 UTC 2019
===== ALIVE Mon Aug 12 10:35:49 UTC 2019
===== ALIVE Mon Aug 12 10:50:49 UTC 2019
===== ALIVE Mon Aug 12 11:05:49 UTC 2019
===== ALIVE Mon Aug 12 11:20:49 UTC 2019
===== ALIVE Mon Aug 12 11:35:50 UTC 2019
===== ALIVE Mon Aug 12 11:50:50 UTC 2019
===== Mon Aug 12 12:00:23 UTC 2019
2019-08-12 12:00:23.604 [error] mqttjs_0d06b7d0@172.24.0.2:54356 [Connection] Parse failed for mqtt_frame_too_large
Stacktrace:[{emqx_frame,parse_remaining_len,5,
[{file,"src/emqx_frame.erl"},{line,81}]},
{emqx_connection,process_incoming,3,
[{file,"src/emqx_connection.erl"},{line,392}]},
{gen_statem,call_state_function,5,
[{file,"gen_statem.erl"},{line,1660}]},
{gen_statem,loop_event_state_function,6,
[{file,"gen_statem.erl"},{line,1023}]},
{proc_lib,wake_up,3,[{file,"proc_lib.erl"},{line,259}]}]
Error data:<<48,167,142,220,1,0,24,109,101,116,97,47,121,111,98,105,116,47,116,
114,97,100,105,110,103,95,112,97,105,114,115,123,34,112,97,105,
114,115,95,100,101,116,97,105,108,115,34,58,123,34,76,84,67,47,66,
84,67,34,58,123,34,108,105,109,105,116,115,34,58,123,34,97,109,
111,117,110,116,34,58,123,34,109,105,110,34,58,48,46,48,48,48,49,
125,44,34,112,114,105,99,101,34,58,123,34,109,105,110,34,58,49,
101,45,56,44,34,109,97,120,34,58,49,48,48,48,48,125,44,34,99,111,
115,116,34,58,123,34,109,105,110,34,58,48,46,48,48,48,49,125,125,
44,34,112,114,101,99,105,115,105,111,110,34,58,123,34,97,109,111,
117,110,116,34,58,56,44,34,112,114,105,99,101,34,58,56,125,44,34,
116,97,107,101,114,34,58,48,46,48,48,50,44,34,109,97,107,101,114,
34,58,48,46,48,48,50,44,34,105,100,34,58,34,108,116,99,95,98,116,
99,34,44,34,115,121,109,98,111,108,34,58,34,76,84,67,47,66,84,67,
34,44,34,98,97,115,101,34,58,34,76,84,67,34,44,34,113,117,111,116,
101,34,58,34,66,84,67,34,44,34,98,97,115,101,73,100,34,58,34,108,
116,99,34,44,34,113,117,111,116,101,73,100,34,58,34,98,116,99,34,
44,34,97,99,116,105,118,101,34,58,116,114,117,101,44,34,105,110,
102,111,34,58,123,34,100,101,99,105,109,97,108,95,112,108,97,99,
101,115,34,58,56,44,34,109,105,110,95,112,114,105,99,101,34,58,49,
101,45,56,44,34,109,97,120,95,112,114,105,99,101,34,58,49,48,48,
48,48,44,34,109,105,110,95,97,109,111,117,110,116,34,58,48,46,48,
48,48,49,44,34,109,105,110,95,116,111,116,97,108,34,58,48,46,48,
48,48,49,44,34,104,105,100,100,101,110,34,58,48,44,34,102,101,101,
34,58,48,46,50,44,34,102,101,101,95,98,117,121,101,114,34,58,48,
46,50,44,34,102,101,101,95,115,101,108,108,101,114,34,58,48,46,50,
125,125,44,34,78,77,67,47,66,84,67,34,58,123,34,108,105,109,105,
116,115,34,58,123,34,97,109,111,117,110,116,34,58,123,34,109,105,
110,34,58,48,46,48,48,48,49,125,44,34,112,114,105,99,101,34,58,
123,34,109,105,110,34,58,49,101,45,56,44,34,109,97,120,34,58,49,
48,48,48,48,125,44,34,99,111,115,116,34,58,123,34,109,105,110,34,
58,48,46,48,48,48,49,125,125,44,34,112,114,101,99,105,115,105,111,
110,34,58,123,34,97,109,111,117,110,116,34,58,56,44,34,112,114,
105,99,101,34,58,56,125,44,34,116,97,107,101,114,34,58,48,46,48,
48,50,44,34,109,97,107,101,114,34,58,48,46,48,48,50,44,34,105,100,
34,58,34,110,109,99,95,98,116,99,34,44,34,115,121,109,98,111,108,
34,58,34,78,77,67,47,66,84,67,34,44,34,98,97,115,101,34,58,34,78,
77,67,34,44,34,113,117,111,116,101,34,58,34,66,84,67,34,44,34,98,
97,115,101,73,100,34,58,34,110,109,99,34,44,34,113,117,111,116,
101,73,100,34,58,34,98,116,99,34,44,34,97,99,116,105,118,101,34,
58,116,114,117,101,44,34,105,110,102,111,34,58,123,34,100,101,99,
105,109,97,108,95,112,108,97,99,101,115,34,58,56,44,34,109,105,
110,95,112,114,105,99,101,34,58,49,101,45,56,44,34,109,97,120,95,
112,114,105,99,101,34,58,49,48,48,48,48,44,34,109,105,110,95,97,
109,111,117,110,116,34,58,48,46,48,48,48,49,44,34,109,105,110,95,
116,111,116,97,108,34,58,48,46,48,48,48,49,44,34,104,105,100,100,
101,110,34,58,48,44,34,102,101,101,34,58,48,46,50,44,34,102,101,
101,95,98,117,121,101,114,34,58,48,46,50,44,34,102,101,101,95,115,
101,108,108,101,114,34,58,48,46,50,125,125,44,34,80,80,67,47,66,
84,67,34,58,123,34,108,105,109,105,116,115,34,58,123,34,97,109,
111,117,110,116,34,58,123,34,109,105,110,34,58,48,46,48,48,48,49,
125,44,34,112,114,105,99,101,34,58,123,34,109,105,110,34,58,49,
101,45,56,44,34,109,97,120,34,58,49,48,48,48,48,125,44,34,99,111,
115,116,34,58,123,34,109,105,110,34,58,48,46,48,48,48,49,125,125,
44,34,112,114,101,99,105,115,105,111,110,34,58,123,34,97,109,111,
117,110,116,34,58,56,44,34,112,114,105,99,101,34,58,56,125,44,34,
116,97,107,101,114,34,58,48,46,48,48,50,44,34,109,97,107,101,114,
34,58,48,46,48,48,50,44,34,105,100,34,58,34,112,112,99,95,98,116,
99,34,44,34,115,121,109,98,111,108,34,58,34,80,80,67,47,66,84,67,
34,44,34,98,97,115,101,34,58,34,80,80,67,34,44,34,113,117,111,116,
101,34,58,34,66,84,67,34,44,34,98,97,115,101,73,100,34,58,34,112,
112,99,34,44,34,113,117,111,116,101,73,100,34,58,34,98,116,99,34,
44,34,97,99,116,105,118,101,34,58,116,114,117,101,44,34,105,110,
102,111,34,58,123,34,100,101,99,105,109,97,108,95,112,108,97,99,
101,115,34,58,56,44,34,109,105,110,95,112,114,105,99,101,34,58,49,
101,45,56,44,34,109,97,120,95,112,114,105,99,101,34,58,49,48,48,
48,48,44,34,109,105,110,95,97,109,111,117,110,116,34,58,48,46,48,
48,48,49,44,34,109,105,110,95,116,111,116,97,108,34,58,48,46,48,
48,48,49,44,34,104,105,100,100,101,110,34,58,48,44,34,102,101,101,
34,58,48,46,50,44,34,102,101,101,95,98,117,121,101,114,34,58,48,
46,50,44,34,102,101,101,95,115,101,108,108,101,114,34,58,48,46,50,
125,125,44,34,68,65,83,72,47,66,84,67,34,58,123,34,108,105,109,
105,116,115,34,58,123,34,97,109,111,117,110,116,34,58,123,34,109,
105,110,34,58,48,46,48,48,48,49,125,44,34,112,114,105,99,101,34,
58,123,34,109,105,110,34,58,49,101,45,56,44,34,109,97,120,34,58,
49,48,48,48,48,125,44,34,99,111,115,116,34,58,123,34,109,105,110,
34,58,48,46,48,48,48,49,125,125,44,34,112,114,101,99,105,115,105,
111,110,34,58,123,34,97,109,111,117,110,116,34,58,56,44,34,112,
114,105>>
(emqx@127.0.0.1)1>
===== ALIVE Mon Aug 12 12:15:23 UTC 2019
===== ALIVE Mon Aug 12 12:30:23 UTC 2019
===== ALIVE Mon Aug 12 12:45:23 UTC 2019
===== ALIVE Mon Aug 12 13:00:24 UTC 2019
===== ALIVE Mon Aug 12 13:15:24 UTC 2019
```
It seems, that `mqtt_frame_too_large` can be fixed with increasing `max_packet_size` from 1 MB to 5 MB.
But I cannot figure out, how to solve error with message_queue_too_long. Can you, please, help with this?