`set_chan_info` does contain the `conn_state`, but it seems that it is
not called for anonymous clients disconnecting.
`emqx_channel:handle_info({sock_closed, normal}, _, _)` is called with
`conn_state := connected` (which decrements by calling
`emqx_channel:ensure_disconnected` and does not call `set_chan_info`),
and afterwards `emqx_cm` receives a `DOWN` message from the same chan.
When the `DOWN` message is received, we check `?CHAN_INFO_TAB` for
that key and check if the persisted state is `connected`. Only in that
case we decrement during `DOWN` messages.
Testing manually, it is still being persisted as `connected`, hence
the double-decrease.
We attempt to solve this by using the ETS as a set with `{ClientID,
ChanPid}` as the key to resolve duplication.
1. Add MQTT5.0 properties when invoking the hooks.
- Add a new key `properties` into the message header:
We used to put all of the properties into the `#message.headers`:
```erlang
#message{headers = #{'User-Property' => {<<"reason">>,<<"normal">>},
'Message-Expiry-Interval' => 60,
allow_publish => true}
```
I put them instead under a single key:
```erlang
#message{headers = #{properties =>
#{'User-Property' => {<<"reason">>,<<"normal">>},
'Message-Expiry-Interval' => 60},
allow_publish => true}
```
Note that the column `properties` may contain all the properties for
Publish and Will messages.
- Add `disconn_props` into the `Channel.conninfo`
- Add `puback_props` also into the message header:
```erlang
#message{headers = #{puback_props =>
#{'User-Property' => {<<"reason">>,<<"normal">>}},
allow_publish => true}
```
2. Change the data type of `#message.headers` and `#message.flags` to map.
It used to support `undefined`.
* Add more test cases for emqx_stats and emqx_os_mon
Fix test case error for emqx_ws_connection
* Add more test cases for emqx_sys_mon
* Update erlang otp to 22.1 for travis ci
* Delete readable=false for make ct
* Add unset_all_env for emqx_zone and update test cases
* Adopt channel architecture and improve the MQTT frame parser
* Update the test cases for emqx_channel, emqx_protocol
- Improve emqx_client to Use the new emqx_frame:parse/2
- Update the ct suites for emqx_channel, emqx_ws_channel
* Fix test case
Fix websocket bug.
Prior to this change, websocket connection would be closed directly
without sending connack packet when acl check fails.
This change fix this bug.