Commit Graph

130 Commits

Author SHA1 Message Date
Feng Lee 681ae511a8 Introduce the 'strict_mode' option and validate MQTT header (#2898)
Introduce the 'strict_mode' option and validate MQTT header
2019-09-16 14:02:31 +08:00
tigercl 35822ff97a
Fix handling for MQTT spec (#2892)
Fix invalid QoS and protocol name, fix handling for Topic-Alias-Maximum and Maximum-Packet-Size, and send DISCONNECT Packet to client when the session is taken over
2019-09-16 13:51:50 +08:00
terry-xiaoyu 1e4c51f080 Send DISCONNECT on packet parse error 2019-09-05 18:16:15 +08:00
Feng Lee 847375d2fb Improve connection and channel modules (#2860)
Improve the connection and channel modules
2019-09-05 14:17:15 +08:00
zhouzb 98072dd3d1 Set stats at connection time 2019-08-26 16:43:08 +08:00
Feng Lee 738145677a Handle the 'discard' cast. 2019-08-23 14:31:33 +08:00
Feng Lee 41e9dad70a Rename `reason` field to `stop_reason` 2019-08-22 23:24:16 +08:00
Feng Lee 8b03371a4a Improve the keepalive, connection, channel and session modules (#2813) 2019-08-22 16:38:25 +08:00
Feng Lee f2b552e29e Ensure stats timer 2019-08-19 09:43:58 +08:00
Feng Lee ae33b6037e Fix the test suites. 2019-08-17 14:39:04 +08:00
Feng Lee f26505d40a Implement session takeover and resumption.
- Implement session takeover
- Remove `init_proc_mng_policy/1' from emqx_misc module
- Remove `conn_proc_mng_policy/1' from emqx_misc module
- Add `emqx_oom' module to monitor OOM of channel process
2019-08-17 13:37:48 +08:00
Feng Lee 1d88f8fd9e Improve the emqx_connection, emqx_ws_connection and emqx_frame modules (#2611)
* 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
2019-06-14 12:44:27 +08:00
Gilbert d3e7d1f0c9 Fix websocket bug (#2615)
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.
2019-06-14 11:33:44 +08:00
turtleDeng a3103cec7b Revert "Fix websocket bug. Prior to this change, websocket connection would be closed directly without sending connack packet when acl check fails."
This reverts commit e73c4c64d0.
2019-06-12 15:51:20 +08:00
GilbertWong e73c4c64d0 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.
2019-06-12 15:49:48 +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
terry-xiaoyu a1eb7ca7d2 Adapt max-heap-size to Arch-32 systems
The erlang:process_flag(max_heap_size, MaxHeapSize) can only set a MaxHeapSize of `small integer`, which is smaller than 2^59 on 64-bit systems, and 2^27 on 32-bit systems.
2019-05-07 17:27:06 +08:00
Gilbert Wong f1616c33d9 Convert value of attribute table to map 2019-04-13 10:35:59 +08:00
Gilbert Wong 81ef5b9b8d Support cookie based auth 2019-04-12 19:25:22 +08:00
Gilbert Wong 7e6255d4ee Set default websocket idle timeout to 2 hour 2019-04-04 17:42:52 +08:00
周子博 6e3c4b0855 Fix conflict 2019-03-27 13:59:26 +08:00
周子博 0fbf771543 Readjust log level into error when got unexpected message 2019-03-27 11:07:58 +08:00
Gilbert 2534b8dc64 Support to pass ws compressing options (#2356)
Add new config entries about websocket
2019-03-27 10:19:35 +08:00
周子博 58e1b4d485 Readjust log level and unify log format 2019-03-26 22:18:31 +08:00
HeeeJianBo fc2df9aff5 Adapt to new export style 2019-03-22 14:58:24 +08:00
Gilbert Wong 763115e149 Delegate serialize fun into sendfun 2019-03-16 21:15:10 +08:00
turtled f1d751dd95 Fix compile fail 2019-02-28 17:06:40 +08:00
turtled c8e2840126 Merge fix conflicts 2019-02-28 17:02:39 +08:00
turtled 42932d7b5d Format code 2019-02-28 16:57:40 +08:00
turtled df97eb0007 Review code 2019-02-28 16:56:44 +08:00
Feng Lee 08204fc7a8 Improve the emqx_connection module using gen_statem behaviour (#2235) 2019-02-28 15:08:29 +08:00
linjun 16165ce935 Use conn_mod instead of socktype 2019-02-28 11:32:05 +08:00
linjun 44529a278d Adjusting code 2019-02-27 14:39:49 +08:00
linjun 7af6051e25 Refactor code 2019-02-27 13:54:24 +08:00
linjun 760ac9f2f9 Add the value of attribute socktype in emqx_conn_type table 2019-02-27 11:09:45 +08:00
张奇怪 44d3eff094 Auto-pull-request-by-2019-02-19 (#2232)
* Update Copyright to 2019 (#2191)

* Disable bridges by default (#2189)

* Fix warning logger args emqx#2195

* Ambiguity elimination (#2217)

* Fix emqx_ws_connection: prevent crashes on pong (#2210)

* Issue#2184 (#2194)

* Delete dep-vsn-check

* Format app.src
2019-02-19 14:00:34 +08:00
turtled 31e95b56c4 Update Copyright to 2019 2019-01-29 10:43:25 +08:00
Feng Lee d7254cdc7f Add more macros for logger 2019-01-04 17:30:27 +08:00
terry-xiaoyu 3b8eb41347 Remove the log header macro 2019-01-04 17:30:27 +08:00
turtled 6f4d517350 Fix conflicts 2018-12-21 17:55:25 +08:00
Feng Lee f31e7f8bde Replace put/2 with emqx_pd:update_counter/2 (#2098) 2018-12-21 17:47:49 +08:00
Gilbert 7d9e350bbe Add option to disconnect client in case acl deny (#2059)
* Add option to disconnect client in case acl deny
2018-12-19 10:34:06 +08:00
周子博 c87aabbbeb Some forgotten changes in last commit 2018-11-30 17:44:29 +08:00
周子博 194dbc02c8 Add batch commit for metrics 2018-11-30 17:44:29 +08:00
Shawn eeb0cab3e3 Update proc meta-data for empty clientid (#1980) 2018-11-23 18:11:46 +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
terry-xiaoyu 82b8047349 Helper funcs for adding proc meta-data 2018-11-19 11:17:58 +08:00
terry-xiaoyu 41315bff0d Log macros for lazy evaluation 2018-11-19 11:17:58 +08:00
terry-xiaoyu 2269967f1a Lazy evaluation when logging messages
Formatting variables and then passing them into the logger functions leads
to performance issues. i.e.

```erlang
logger:debug("RECV ~s", [emqx_packet:format(Packet)])
```

Above message will only be printed when the current log level set to
`debug`, but the function emqx_packet:format/1 will always be evaluated no
matter what the current log level is.

OTP 21 provides a special meta-data named `report_cb`, which can be used
for lazy evaluation. The fun is only evaluated if the primary/handler log level
check passes, and is therefore recommended if it is expensive to generate
the message.
2018-11-19 11:17:58 +08:00
turtled faeda253e1 Fix conflicts 2018-11-10 11:44:55 +08:00
Gilbert Wong 4ea57c2bf9 Delete redundant case clauses in sendfun
Prior to this change, there are ok, {binary, _Data}. {datagram, _Peer,
_Dara} case clauses, and the {binary, _Data} and {datagram, _Peer,
_Data} are unnecessary cases

This change delete these two cases and add ok in the end of funtion in
send_fun of emqx_ws_connection.
2018-11-03 22:56:11 +08:00
terry-xiaoyu 94dbdffd59 New logger formatter with meta-data 2018-11-02 18:38:07 +08:00
Gilbert Wong 35460d8227 Refactor send_fun 2018-10-22 09:04:03 +08:00
Gilbert Wong a748e8f1d8 Refactor send_fun in protocol and other connection module
Prior to this change, in the send function, the packet is forced to
use emqx:serialize to serialize packet, it is a wrong design because
other plugins which need to transform the mqtt packet to other packets
can not use their own serialize function to serialize packet.

This change solve the problem issued above.
2018-10-18 13:24:06 +08:00
turtleDeng 8653732bae Revert "Calculate the 1.5 keep alive time exactly" 2018-09-22 14:52:31 +08:00
周子博 aade94711c Use process dictionaries to record last packet timestamp 2018-09-21 18:50:26 +08:00
周子博 073bf481c9 Calculate the 1.5 keep alive time exactly 2018-09-20 15:51:28 +08:00
Feng Lee ea1ae70833 Fix errors found by dialyzer 2018-08-31 16:46:51 +08:00
Feng Lee 0379219a04 Improve the design of session discard 2018-08-30 23:14:09 +08:00
terry-xiaoyu 8a5519cafa attrs for ws_connection 2018-08-30 14:32:31 +08:00
turtled 98698d318f ws disconnect call emqx_protocol:shutdown 2018-08-29 21:39:09 +08:00
turtled af21cdfd1b Rm tmp var 2018-08-29 10:08:15 +08:00
turtled 00cb26c4e0 Support ws mqtt any version 2018-08-29 10:00:41 +08:00
turtled 013a5a9c7c Fix emqx_protocol:clientid undefined 2018-08-29 09:30:18 +08:00
Feng Lee 475319b907 Merge emqx30-feng branch 2018-08-27 21:36:43 +08:00
Feng Lee 1607e576de Update connection, session, stats modules 2018-08-27 21:34:11 +08:00
turtled 35d821a62e Add WS stats 2018-08-27 16:15:23 +08:00
turtled 6478f811bf Fix conflicts 2018-08-27 10:29:22 +08:00
turtled 1448515e64 Fix websocket bug 2018-08-27 10:14:58 +08:00
Feng Lee 0e3728c940 Add emqx_types module and 'credentials' type 2018-08-26 16:24:51 +08:00
Feng Lee 0f052ce352 Upgrade connection, protocol and session modules for MQTT 5.0 2018-08-24 18:39:59 +08:00
Feng Lee f80cd2d986 Improve the MQTT over Websocket connection 2018-08-11 17:57:19 +08:00
turtled 4d9e03a803 Refactor websocket conn using cowboy 2018-08-08 18:36:14 +08:00
Feng Lee 7d0cba9427 Add MQTT 5.0 supports for connection, protocol and session modules 2018-08-06 16:33:10 +08:00
Feng Lee bffdd2ba74 Upgrade esockd and add more test cases 2018-05-22 13:01:19 +08:00
Feng Lee 2a4ffc6645 Add more service modules for MQTT Version 5.0 2018-04-18 16:34:23 +08:00
Feng Lee 71acf91ace Replace lager with emqx_log 2018-04-09 12:34:53 +08:00
Feng Lee 9976327c8d Add emqx_mqtt module 2018-03-23 18:13:09 +08:00
Feng Lee 282e341433 EMQ X R3.0 - Improve the design of pubsub and router 2018-03-21 16:48:52 +08:00
Feng Lee 22350f9117 Depends on canel-lock library 2018-03-09 13:26:46 +08:00