Commit Graph

49 Commits

Author SHA1 Message Date
Zaiming (Stone) Shi 14ba75502f chore: update copyright year 2023-01-02 14:54:38 +01:00
Xinyu Liu 2a89443377
Merge branch 'main-v4.4' into copy-of_main-v4.3 2022-06-29 22:27:49 +08:00
Thales Macedo Garitezi 5c89998049 fix(hooks): return error on hook-removed subscription rather than deleting it
Following https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901178
2022-06-29 11:08:22 -03:00
Xinyu Liu 565b6b0eb3
Merge branch 'main-v4.4' into copy-of_main-v4.3 2022-06-23 22:44:53 +08:00
Thales Macedo Garitezi 4bda62b195 fix(hooks): use hook response to stop subscriptions
Fixes https://github.com/emqx/emqx-lua-hook/issues/118

1) If the Lua hook returns an empty list, it should replace the final
topic filter list.
2) The subscribed topics after running the 'client.subscribe' hook
should not contain topics filtered out by the hooks.
2022-06-21 17:06:39 -03:00
Thales Macedo Garitezi b93a0743ac Merge branch 'main-v4.3' into 'main-v4.4' 2022-06-15 10:48:02 -03:00
Thales Macedo Garitezi 1ba8ad4c25
fix(metrics): inc `connack.auth_error` when using MQTT 3.1
Since MQTT 3.1 uses a different reason code for auth failures, it was
failing to increase the corresponding metric that works for MQTT 5.0.
2022-06-10 15:00:57 -03:00
JianBo He 89c65b6535 Merge tag 'v4.3.14-rc.4' into merge-main-v4.3-into-v4.4 2022-04-16 11:28:07 +08:00
JimMoen 6168745f90 chore: update copyright 2022-04-14 11:23:25 +08:00
Thales Macedo Garitezi d435f1211e
fix(live_conn): fix live connection count on race condition
When multiple clients try to connect concurrently using the same
client ID, they all call `emqx_channel:ensure_connected`, increasing
the live connection count, but only one will successfully acquire the
lock for that client ID.  This means that all other clients that
increased the live connection count will not get to call neither
`emqx_channel:ensure_disconnected` nor be monitored for `DOWN`
messages, effectively causing a count leak.

By moving the increment to `emqx_cm:register_channel`, which is only
called inside the lock, we can remove this leakage.

Also, during the handling of `DOWN` messages, we now iterate over all
channel PIDs returned by `eqmx_misc:drain_down`, since it could be
that one or more PIDs are not contained in the `pmon` state.
2021-12-08 10:33:57 -03:00
Thales Macedo Garitezi b9270ad719
feat(stats): track live / connected channel count for monitoring
In order to correctly display the number of connected clients in our
monitor dashboard, we need to track those connections that are
actually connected to clients, not considering connections from
persistent sessions that are disconnected.  Today, the
`connections.count` that is displayed in the dashboards considers
those disconnected persistent sessions as well.
2021-11-08 14:45:57 -03:00
Zaiming Shi 3fa442f4a4 test(emqx_broker): fix flaky tests 2021-10-05 20:55:36 +02:00
Rory Z ff96250b0b chore(tests): fix conunt error 2021-08-06 15:31:32 +08:00
Zaiming Shi 6354e75626 chore: update copyrights 2021-04-23 20:43:00 +02:00
JianBo He 739e49218f
fix(cm): fix the problem of registering a channel twice (#3831) 2020-12-28 11:03:29 +08:00
Zaiming Shi d67212e7fa chore(test): Make test profile build 2020-12-11 08:19:26 +01:00
JianBo He e3489b9d46 refactor(style): improve all types declaration
- Add dialyzer for code analysis
- Correct all the module type declarations
- Use `-type()` to declaration a type instead of `-opaque`
  (It is advantageous to the code dialyzer)

BROKEN CHANGES:
- Add a ?DEFAULT_SUBOPTS for emqx_broker:subscribe/1,2,3
- Remove the needless internal function `emqx_vm:port_info(PortTerm, Keys)`
2020-06-18 17:38:34 +08:00
zhanghongtong e5a6e0dcce Fix test case error 2020-03-27 19:40:30 +08:00
zhouzb 7ea75f4289 Update copyright 2020-01-03 18:31:08 +08:00
Feng Lee c5c99b7c4e Improve 'emqx_ws_connection' module and add more test cases 2019-12-13 18:07:59 +08:00
Feng Lee 9c3273a2c6 Improve the process of handling MQTT control packets (#3079) 2019-12-06 19:51:06 +08:00
zhouzb c5ad674dd7 Add test cases and fix bugs 2019-11-01 15:48:28 +08:00
Feng Lee 7be110cdef Add more test cases 2019-10-23 16:35:15 +08:00
Feng Lee 7175e4a74c Set 'boot_modules' when starting emqx apps. 2019-09-06 17:36:34 +08:00
turtled 91a8dbda56 Fix conflicts 2019-08-09 16:41:11 +08:00
Feng Lee 4afa02ee48 Update all the test cases 2019-08-06 09:04:37 +08:00
Feng Lee c8317a230d Update copyright 2019-08-03 11:43:30 +08:00
terry-xiaoyu b0e2b7db0c Support inter-node messages via RPC cast 2019-07-27 12:59:07 +08:00
Feng Lee f801ff1e53 Optimize metrics using counters and persistent_term (#2597)
* Optimize emqx_metrics module using persistent_term and counters in OTP 22
2019-06-05 23:16:35 +08:00
Gilbert Wong b3927ff730 Add emqx_ct_helpers as deps and refactor test suites 2019-04-25 13:41:22 +08:00
Gilbert Wong d020ac0390 Delay receive waiting time 2019-03-18 14:20:52 +08:00
Shawn 02fe8560e2
Improve emqx_hooks and credentials (#2309)
* Improve emqx_hooks and credentials

1. Modify the return modes of emqx hooks.

Change the return value of hook functions to:
- ok: stop the hook chain and return ok
- {error, Reason}: stop the hook chain and return error
- continue: continue the hook chain

And the return value of emqx_hooks:run/2 is changed to:
- ok
- {error, Reason}

And the return value of emqx_hooks:run/3:
- {ok, Acc}
- {error, Reason, Acc}

2. Treat password as a member of credentials.

Password should be wrapped in the `credentials` data-structure, as the
username/password pair together consists of an authentication method.
There can be some methods using some other credential data (e.g.
a JWT token), and these credential data should also be wrapped in the
the `credentials` data-structure.

An event `client.authenticate` is triggered when an user logs in:
```erlang
emqx_hooks:run('client.authenticate', [], Credentials)
```

A `default callback` that deny/allow any user (according to the
`allow_anonymous` config) should be appended to the end of the
callback chain.

The `credentails` is passed through all of the callbacks, and
can be changed over in this process.

* Refactor emqx hooks return mode

* Remove password from PState
2019-03-16 10:43:53 +08:00
tigercl da755b88c7 Add monitors and alarm handler (#2266)
* Add monitors and alarm handler
2019-02-28 18:25:17 +08:00
turtled 31e95b56c4 Update Copyright to 2019 2019-01-29 10:43:25 +08:00
turtled 7a1ec580b0 Update broker test cases 2018-12-19 17:18:26 +08:00
Gilbert Wong e0eb76afa6 Fix subscription 2018-12-08 16:09:54 +08:00
Gilbert 295a9d692e
Fix the coverage shaky (#2010) 2018-11-30 19:16:48 +08:00
spring2maz a2c658ba19 Add acking mechamism for shared dispatch (#1872)
* Add acking mechamism for shared dispatch

For QoS0 messages, no acking
For QoS1/2 messages, 'ACK' at any of events below:
 - ACK when QoS is downgraded to 0
 - Message is sent to connection process
'NACK' at any of events below:
 - Message queue is full and the receiving session starts to drop old messages
 - The receiving session crash
Upon 'NACK', messages are dispatched to the 'next' subscriber in the group,
depending on the shared subscription dispatch strategy.
2018-11-21 22:49:45 +08:00
Gilbert 16821490ce Fix issue#1874 (#1964)
* Fix issue#1874
Prior to this change, if user use one client connect emqx with mqtt
v3.1.1, the client subscribe the topic and publish message to this
topic, it would receive this message itself published, this commit
provide a configure option to let user ignore the message itself published.

This change fix issue 1874.

* Small Fix

* Fix bug

* Better design

* Fix compile warning and improve coverage

* Better design to solve the performance issue

* Fix typo

* Fix typo

* Delete spaces in end of lines.

* Do not use anonymous function

* Better performance
2018-11-19 13:34:03 +08:00
tigercl abb2e5c918
Improve test cases, and fix some bugs (#1920)
* Improve emqx_banned, emqx_pqueue, emqx_router test cases

* Improve emqx_broker test case, and fix bug in emqx_broker

* Add emqx_hooks to CT_SUITES
2018-10-26 17:27:02 +08:00
spring2maz 0b0ef9bd54 Fix default QoS in test cases 2018-09-25 22:09:13 +08:00
周子博 08bab7efa4 Fix bugs in test cases 2018-09-08 11:49:20 +08:00
Feng Lee 2a75105580 Improve the Hooks's design 2018-09-06 16:27:16 +08:00
Gilbert Wong 2f63b7a487 update broker suite for latest code 2018-08-31 20:21:28 +08:00
Feng Lee 41d1f04659 Update copyright 2018-08-28 20:37:46 +08:00
Gilbert Wong ce3f2e4d9e fix emqx_broker test suite 2018-08-27 21:18:00 +08:00
HuangDan e3fb147594 Fixed test case compilation error 2018-08-26 22:25:54 +08:00
Feng Lee bffdd2ba74 Upgrade esockd and add more test cases 2018-05-22 13:01:19 +08:00
Feng Lee fcb2ec8427 Merge the latest enterprise branch 2018-02-24 15:56:32 +08:00