Commit Graph

810 Commits

Author SHA1 Message Date
zhongwencool 761436c967 fix: don't allow empty username if username_as_clientid is true 2022-05-05 10:50:53 +08:00
firest 8a269099ad fix(frame): remove empty topic check, because it checked in emqx_channel 2022-04-18 14:23:22 +08:00
JimMoen 6168745f90 chore: update copyright 2022-04-14 11:23:25 +08:00
firest 2c47869426 test(frame): fix empty topic name case not running 2022-04-12 18:40:37 +08:00
firest eec204517f fix(frame): fix empty topic check error 2022-04-08 16:26:07 +08:00
JianBo He bf1a3fe1eb chore: eliminate some compiling warnings and improve change logs 2022-04-08 11:16:37 +08:00
Georgy Sychev 0c74227995 feat(shared_sub): per group strategies and local strategy
Adds backward compatible per group strategy for shared subscriptions
Adds local shared subscription strategy
2022-04-07 13:40:02 +04:00
Thales Macedo Garitezi aa19283ff2
fix: ensure default values for `loaded_{plugins,modules}`
Fixes #7455 .

This tries to populate `loaded_{plugins,modules}` files with default
values before loading them, in case they don't exist.
2022-04-06 09:08:21 -03:00
firest bf68735664 fix(frame): forbidden empty topic in strict mode 2022-03-30 10:42:56 +08:00
JianBo He 706c7725f9 test: update test/emqx_channel_SUITE.erl
Co-authored-by: Thales Macedo Garitezi <thalesmg@gmail.com>
2022-03-21 10:56:55 +08:00
JianBo He 604c384660 fix(channel): send will_msg if client has been kicked 2022-03-21 10:56:55 +08:00
JianBo He 8d3e953eef fix(channel): send DISCONNECT packet if connection has been kicked
fix #7241
2022-03-21 10:56:37 +08:00
JimMoen dce513df0e test(frame): malformed utf-8 packet 2022-03-10 11:39:44 +08:00
zhongwencool b1816a6647 fix: add uptime/1 for CT test. 2022-03-01 14:19:37 +08:00
Thales Macedo Garitezi 6b93127ecb
fix(sys_mon): guard before calling `erlang:port_info`
Port of #7108 .

Sometimes, the `emqx_sys_mon:procinfo/1` might be called with
something that is not a port, like `[]`.  Not sure on the conditions
for this to happen.

```
2022-02-18T20:05:02.671592+00:00 [error] Generic server emqx_sys_mon terminating. Reason: {badarg,[{erlang,port_info,[[]],[{error_info,#{module => erl_erts_errors}}]},{emqx_sys_mon,portinfo,1,[{file,"/emqx/apps/emqx/src/emqx_sys_mon.erl"},{line,205}]},{emqx_sys_mon,'-handle_info/2-fun-5-',2,[{file,"/emqx/apps/emqx/src/emqx_sys_mon.erl"},{line,150}]},{emqx_sys_mon,suppress,3,[{file,"/emqx/apps/emqx/src/emqx_sys_mon.erl"},{line,184}]},{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,695}]},{gen_server,handle_msg,6,[{file,"gen_server.erl"},{line,771}]},{proc_lib,wake_up,3,[{file,"proc_lib.erl"},{line,236}]}]}. Last message: {monitor,<0.7796.0>,busy_dist_port,[]}. State: #{events => [{busy_dist_port,#Port<0.127>}],timer => #Ref<0.2758388682.1853620226.133920>}.
```
2022-02-24 16:28:35 -03:00
JianBo He f121f9616e chore: rename testcase name 2022-02-24 17:26:17 +08:00
JianBo He 66807f17df test(cm): cover {takeover, 'begin'/'end'} action 2022-02-24 09:53:17 +08:00
Thales Macedo Garitezi 8302cac329
fix(channel): wrong case clause when alias is inexistent
Fixes #6978 .
2022-02-14 13:18:07 -03:00
Thales Macedo Garitezi b968d4c416
fix(ctl): fix formatting when printing messages without arguments (4.3)
Without passing an empty argument list to `emqx_ctl:print`, formatting
instructions like `~n` are being printed literally.

```
Ignore.~nJoin the cluster successfully.~nCluster status: #{running_nodes =>
                      ['emqx@emqx-0.int.thalesmg','emqx@emqx-1.int.thalesmg',
                       'emqx@emqx-2.int.thalesmg','emqx@emqx-3.int.thalesmg',
                       'emqx@emqx-4.int.thalesmg'],
                  stopped_nodes => []}
```
2022-02-09 09:36:27 -03:00
zhongwencool 9d633507f5 fix(appup): add emqx.erl to appup.src 2022-01-26 14:32:00 +08:00
zhongwencool 78f294cda2 fix: sys_mem alarm is not triggered after reboot. 2022-01-25 16:12:17 +08:00
Shawn a63799742f fix(channel): update testcases for emqx_channel 2022-01-13 16:10:03 +08:00
Shawn a6408cee4f fix(session): update testcases for emqx_session 2022-01-13 15:28:18 +08:00
JianBo He cb8a3725b4 fix: disconnect the client due to exceed receive-maximum packets
As described in the 5.0 specification, we should disconnect clients that
exceed the receive-maximum limit.

> If it receives more than Receive Maximum QoS 1 and QoS 2 PUBLISH packets
where it has not sent a PUBACK or PUBCOMP in response, **the Server uses a
DISCONNECT packet with Reason Code 0x9**

fix: #6447
2021-12-23 08:48:24 +08:00
JimMoen 3ecc79e1bc test(frame): test packet proxy_protocol config disabled 2021-12-10 18:08:47 +08:00
Thales Macedo Garitezi 0260db6640
feat(sys_mon): Add proc_lib:initial_call/1 and current_stacktrace (4.3)
(Same as #6289 )

This adds the information from `proc_lib:initial_call/1` and the
current stacktrace from the process info to `emqx_sys_mon:procinfo/1`
to aid in debugging some warnings with no context such as the
following:

```
2021-11-23T12:33:59.387818+00:00 [warning] info: [{old_heap_block_size,45988046},{heap_block_size,22177879},{mbuf_size,0},{stack_size,40},{old_heap_size,22354134},{heap_size,7106339}], line: 130, mfa: emqx_sys_mon:handle_info/2, msg: large_heap, procinfo: [{pid,<0.2667.0>},{memory,579763664},{total_heap_size,68510672},{heap_size,22177879},{stack_size,40},{min_heap_size,233},{initial_call,{proc_lib,init_p,5}},{current_function,{gen,do_call,4}},{registered_name,[]},{status,running},{message_queue_len,360945},{group_leader,<0.1660.0>},{priority,normal},{trap_exit,false},{reductions,16493271},{last_calls,false},{catchlevel,4},{trace,0},{suspending,[]},{sequential_trace_token,[]},{error_handler,error_handler}]
```
2021-11-25 12:08:02 -03:00
JimMoen 289415b5aa fix(conf): change `max_topic_levels` default configuration 2021-11-25 09:52:12 +08:00
zhouzb 5e3fe6714e fix(http): fix duplicate http headers 2021-11-17 14:14:12 +08:00
Zaiming Shi 74b6b5214a test(emqx_cm_SUITE): add a gen_server call sync 2021-11-11 10:33:31 +01:00
zhongwencool fa34d8353e
fix(test): flaky mqtt expiry test case. (#6112) 2021-11-10 15:40:46 +08:00
Zaiming Shi 7f4809f61a fix(session): force kill session for 'kick' and 'discard'
Prior to this fix, 'kick' and 'discard' calls may timeout (or
fail for other reason), failures lead to only a log, then
continue to allow the new session to get registered.

As a result, in case a client is stuck, there is no way to
force it to step down, end up with multiple connections (sessions)
for the client ID in dashboard.

After this fix, the stale pids are notified to shutdown
via a gen_server:call, and forced with a exit(Pid, kill) for any
exception happend to the gen_server:call
2021-10-30 16:38:36 +02:00
Zaiming Shi 9038da0bd2 fix(ws_connection): check origin failure should return 403 not 500 2021-10-15 15:49:26 +08:00
Zaiming Shi 7c1ce8bc70 chore: fix flaky test cm_SUITE open session racecondition 2021-10-07 11:53:53 +02:00
Zaiming Shi 3fa442f4a4 test(emqx_broker): fix flaky tests 2021-10-05 20:55:36 +02:00
JimMoen 2dba91d6d0 chore(test): variable integer test. 2021-09-28 15:15:05 +08:00
k32 5fc1036cf7 chore(mqueue): Implement live upgrade 2021-09-06 23:15:14 +02:00
k32 4eacaa29bd feat(mqueue): Interleave messages with different priorities 2021-09-06 22:22:48 +02:00
Turtle 6aa61ea78d fix(test): Increase the delay time 2021-08-13 17:29:51 +08:00
Rory Z ff96250b0b chore(tests): fix conunt error 2021-08-06 15:31:32 +08:00
Turtle c45de03ac8 chore(version): update emqx version to 4.3.7
Signed-off-by: zhanghongtong <rory-z@outlook.com>
2021-08-05 10:00:03 +08:00
JianBo He 07c29e8c55 chore(acl): support ipaddr list 2021-07-28 13:54:13 +08:00
Zaiming Shi cddfa928b1 test: deterministic tests 2021-06-05 19:53:56 +02:00
Zaiming Shi 8bf3c511d8 test: fix a flacky test case 2021-06-04 16:04:58 +02:00
Tobias Lindahl 18484577b1 test: enable non-running test suite
Due to a name clash a ct testsuite was previously not running.
2021-06-03 10:42:51 +02:00
JianBo He 3a89b1f00b
chore(action): fix syntax error (#4885) 2021-05-31 15:08:52 +08:00
k32 812faf08a1 chore(logger): Update snabbkaffe to 0.13.0 2021-05-25 21:15:59 +02:00
Zaiming (Stone) Shi 37c559a08d
Merge pull request #4858 from zmstone/fix-frame-parse-split-function-clause
fix(emqx_frame): no need to split incoming bytes
2021-05-25 06:57:17 +02:00
Zaiming Shi 979e495a1e fix(emqx_frame): no need to split incoming bytes
Prior to this commit, there was a bug in emqx_frame:split/2
the tail number of bytes was used for header number of bytes
whens split. As a result, if the tail happens to be longer
then haeder, the parsing state becomes invalid and it crashes
when the next packet arrives

The split was a over-engineered micro-optimization, so it
has been deleted instead of fixed
2021-05-24 21:07:03 +02:00
Zaiming Shi 6701d716dd feat: async API to support tcp keepalive inet options 2021-05-24 19:01:13 +02:00
Zaiming Shi 8443aa5e21 chore(typo): sepecial -> special 2021-05-24 10:45:56 +02:00
Zaiming Shi faecde9ce1 fix(emqx_plugins): allow loading conf for plugin app dir
Prior to this change, plugin config files are only allowed
to be placed in the collective config dir etc/plugins.
In order to support external plugin's drop-in deployment,
this commit made emqx_plugins module to read conf file
in application's etc dir
2021-05-24 10:45:56 +02:00
Zaiming Shi 4e1798e3f3 fix(emqx_cm): do not log noproc as error
1. websocket call exit with noproc reason.
2. do not capture stacktrace when no need for it
2021-05-19 23:16:11 +02:00
Zaiming Shi 55316b3ac3 perf: micro optimisation: no lookup for non-wildcard in trie 2021-05-14 10:45:58 +02:00
Zaiming Shi 3c03047c9f fix(emqx_trie): performance issue when many levels 2021-05-14 10:45:58 +02:00
Zaiming Shi 05c5378265 feat(http_lib): add normalise_headers API 2021-05-07 10:14:19 +08:00
Zaiming Shi f8700e3f27 fix(emqx_packet): no crash if publish packet has no data 2021-05-04 13:48:35 +02:00
Zaiming Shi 29475eb610 feat(emqx_http_lib): try to parse host ip 2021-04-28 10:43:36 +02:00
Zaiming Shi eb946eb80c fix(emqx_trie): do not try to match wildcard topics 2021-04-26 14:18:40 +02:00
Zaiming Shi 22e72cdd82 refactor(emqx_trie): rename record from eqmx_topic to emqx_trie 2021-04-26 14:18:40 +02:00
Zaiming Shi bc6a87946c refactor(emqx_trie): store only prefixes
This commit refactors emqx_trie implementation
with mainly two changes

1. Deleted the edge table.

   In the old implementation, trie consist of nodes and edges.
   e.g. for topic 'a/b/+/d', node 'a' with edge 'b'
   points to node 'a/b' and so on.

   However, edges can be computed at runtime,
   so there is no need to store them in a table.
2021-04-26 14:18:40 +02:00
Zaiming Shi d61b100cc9 chore: more copyright updates 2021-04-23 20:43:00 +02:00
Zaiming Shi 6354e75626 chore: update copyrights 2021-04-23 20:43:00 +02:00
Zaiming Shi c81df7278f test(trace): split test case 2021-04-23 06:54:10 +02:00
Zaiming Shi 3547dc4c93 fix(log): client id as string for log metadata
so it does not print <<"...">> to the logs
2021-04-23 06:54:10 +02:00
Zaiming Shi fd69969014 refactor(logging): Log to single line 2021-04-23 06:54:10 +02:00
JianBo He 1f258a0499 test(proper): fix cant_generate error 2021-04-19 22:03:51 +02:00
Shawn 47817ea28d fix(emqx): meck emqx_connection:call/3 in testcase 2021-04-16 13:37:24 +08:00
Shawn 4885171e4f fix(emqx): add timeout for open/kick a session 2021-04-15 23:09:58 +08:00
Shawn ebac8c1612 fix(emqx): set the timetrap of emqx_cm_SUITE to 1 min 2021-04-15 23:09:58 +08:00
JianBo He 04cbb3751d test(proper): wait tcp port closed 2021-04-15 21:18:17 +08:00
JianBo He 4a388400a5 test(proper): ensure epmd started 2021-04-14 19:38:56 +08:00
JianBo He c413af5c35 test(proper): track to the lastest code
- use limited atom type
- keep webhook confs testing to lastest schema
2021-04-14 19:38:56 +08:00
JianBo He eb8c8021f0 test(proper): spefic the nodename for checking 2021-04-14 19:38:56 +08:00
z8674558 a48e7df4f5 feat(emqx_ws_connection): check http header to know real IP/port 2021-04-14 06:45:39 +00:00
JianBo He 16c999ed9b
Start emqx-modules application by default (#4518)
* fix(modules): start emqx_modules by default

* chore(test): eliminate some compile warnings
2021-04-12 09:45:31 +08:00
Zaiming Shi 25e0e121e5 chore(test): ensure snabbkaffe block until is not timeout 2021-04-09 10:18:25 +02:00
Zaiming Shi b3b821e8c4 fix(flase): false 2021-04-08 00:34:43 +02:00
Zaiming Shi 6f5aa88562 chore(emqx_connection): Add a test case to cover oom kill 2021-03-30 10:08:13 +02:00
Zaiming Shi 5e2ba1cdc3 chore: Fix emqx_channel_SUITE meck orders 2021-03-29 09:42:07 +02:00
Zaiming Shi e579c7624b chore(channel): Add test case for receive-maximum check and override 2021-03-29 09:42:07 +02:00
zhanghongtong 72c1ee264c chore(elvis): fix elvis error 2021-03-19 16:11:23 +08:00
zhanghongtong 568f4de6e5 fix(channel): fix the wrong acl check order
when subscribe, check the acl rule before run 'client.subscribe' hooks
2021-03-19 16:11:23 +08:00
Shawn 81602c973c fix(emqx): deny pingreq when mqtt not connected #4370 2021-03-19 14:17:49 +08:00
zhouzb fa8b2a5ac5 chore(test-cswsh): add test case for cswsh 2021-03-19 10:28:13 +08:00
Karol Kaczmarek c7b44caa1d feat(acl): Add possibility to remove all acl cache 2021-03-17 19:48:42 +01:00
Shawn d6797760a1 fix(test): add testcases for ws subprotocols 2021-03-17 14:59:05 +08:00
z8674558 9087f0c138 feat(emqx_message): add from_map 2021-03-11 16:01:30 +09:00
Shawn b400571dbb fix(emqx): validate mqtt malformed varible byte integer 2021-03-10 10:41:57 +01:00
Zaiming Shi c752f3bec5
Refactor http lib add uri parse (#4292)
* feat(http_lib): Add uri parse to emqx_http_lib

* fix(webhook): call emqx_http_lib to parse uri

* fix(auth-http): Call emqx_http_lib to parse uri

* fix(rule-engine): call emqx_http_lib to parse uri
2021-03-06 13:35:02 +08:00
Zaiming Shi 63c001a7aa refactor(http-lib): Add emqx_http_lib
So far only uri_encode and uri_decode APIs
2021-03-03 21:38:10 +01:00
Zaiming Shi 6e0b53fbb9 fix(eunit): fix emqx_tls_lib_tests 2021-03-01 21:00:17 +08:00
Zaiming Shi 3dfa9f45c4
Merge pull request #4183 from zmstone/merge-e4.2.4-to-dev-4.3.0
Merge e4.2.4 to dev 4.3.0
2021-02-19 10:26:47 +01:00
Shawn eec64e440d
fix(tracer): create short handler-id if clientid is too long (#4164)
* fix(tracer): create short handler-id if clientid is too long

No need to support lists and atoms for when tracing clients/topics.
2021-02-16 14:45:33 +08:00
Zaiming Shi f9465dda16 Merge branch 'dev/v4.3.0' into merge-e4.2.4-to-dev-4.3.0 2021-02-14 21:41:23 +01:00
Zaiming Shi b4b318cb86 chore(style): fix elvis check for emqx_connection_SUITE 2021-02-13 11:41:18 +01:00
Zaiming Shi 9b82112b7c Merge remote-tracking branch 'origin/dev/e4.3.0' into merge-e4.2.4-to-dev-4.3.0 2021-02-13 11:10:08 +01:00
Zaiming Shi 507759b9f1 Revert "refactor(emqx_modules): Move modules config to app dir"
This reverts commit 9cae8784c0.
Because the reverted change broke compatibility with 4.2.x
configuration.
2021-02-11 16:44:12 +01:00
Zaiming Shi 514c2c0af5
Merge pull request #4169 from zmstone/refactor-move-modules-config-to-emqx-modules-app
refactor(emqx_modules): Move modules config to app dir
2021-02-10 09:03:04 +01:00
Zaiming Shi d74bb81ff1 chore(style): make elvis happy 2021-02-10 00:02:52 +01:00
Zaiming Shi 9cae8784c0 refactor(emqx_modules): Move modules config to app dir 2021-02-10 00:02:52 +01:00