Commit Graph

2421 Commits

Author SHA1 Message Date
Feng Lee a318532bb0 Tuning the 'force_gc_policy' of MQTT connections (#3192)
Tuning the 'force_gc_policy' of MQTT connections
2020-01-17 09:42:16 +08:00
Feng Lee 2b3003b323 Move the global GC server from 'emqx-recon' to 'emqx' project (#3190) 2020-01-16 23:45:17 +08:00
turtleDeng f6b2c9a69f Correct timestamp for banned (#3188) 2020-01-16 23:11:19 +08:00
Feng Lee 2ba624ac31 Add 'compose/1', 'compose/2' functions 2020-01-13 21:00:40 +08:00
zhanghongtong fdeade3212 Add more test cases 2020-01-09 20:01:46 +08:00
JianBo He b1a22931f4
Add testcase for takeover (#3160) 2020-01-09 12:26:24 +08:00
JianBo He 7d3a08dc13
Improve 'client.connect', 'client.connack' hooks (#3153) 2020-01-04 10:44:17 +08:00
turtleDeng 6b8ffc386a Fix WS reason code (#3149) 2020-01-04 10:06:50 +08:00
zhouzb 7ea75f4289 Update copyright 2020-01-03 18:31:08 +08:00
turtled f33217c049 Fix unexpected timeout 2019-12-31 09:06:58 +08:00
zhouzb 597558fee8 Fix unexpected timeout 2019-12-30 21:27:47 +08:00
Feng Lee 46ca3f2f82 Add metrics for session's lifecircle
- session.created
- session.resumed
- session.takeovered
- session.discarded
- session.terminated
2019-12-30 09:29:41 +08:00
Feng Lee 12c6d5fe2c Add more metrics for client's lifecircle
- client.connect
- client.connack
- client.connected
- client.authenticate
- client.check_acl
- client.subscribe
- client.unsubscribe
- client.disconnected
2019-12-30 09:28:55 +08:00
Feng Lee 9a3d16c654 Add 'emqx_packet:info/2' function and test cases 2019-12-30 09:28:38 +08:00
Feng Lee b7ca3905a6 Breaking Change: Add new hooks for client and session lifecircle (#3138) 2019-12-27 16:31:06 +08:00
JianBo He d000284a40 Merge branch 'caps' into develop 2019-12-21 16:04:41 +08:00
turtleDeng b612674ffa
Update emqx_mqtt_caps.erl 2019-12-21 14:16:37 +08:00
JianBo He b3eed9123f Fix typo 2019-12-21 10:39:02 +08:00
Feng Lee 578355442b Add more metrics and improve the 'channel', 'session' modules (#3128) 2019-12-20 21:47:32 +08:00
张奇怪 2cf3af12ef Update test cases for emqx_connection (#3116) 2019-12-20 19:15:45 +08:00
tigercl 116c593178 Fix returned value of plugin reloading (#3126) 2019-12-20 16:34:07 +08:00
JianBo He 9b9df46718
Add sockport to ClientInfo (#3122) 2019-12-19 13:34:24 +08:00
zhouzb 70ae3c75a0 Remove emqx_time module 2019-12-17 09:38:33 +08:00
turtled eea5e14b0c Fix event/message out of order 2019-12-16 22:12:56 +08:00
Feng Lee 814f103e34 Fix issue#3109 - remove the 'sessions.persistent.count', 'sessions.persistent.max' stats 2019-12-16 16:41:42 +08:00
Feng Lee 1f25f4439f Remove the 'stop_reason' field 2019-12-16 12:45:46 +08:00
Feng Lee 635c3f75fe Improve the 'emqx_connection' module for CT 2019-12-16 11:25:47 +08:00
Feng Lee ad9e0fc311 Support the 'clean_start = false' websocket connection 2019-12-16 11:25:47 +08:00
Feng Lee 2ef52828bc Improve 'emqx_connection' module and update test cases 2019-12-16 11:25:47 +08:00
zhouzb 7ac60678de Add test cases for emqx_cm and emqx_router_helper modules 2019-12-13 18:09:48 +08:00
Feng Lee c5c99b7c4e Improve 'emqx_ws_connection' module and add more test cases 2019-12-13 18:07:59 +08:00
tigercl 2a3baed7e0
Merge pull request #3103 from emqx/ws-conn-ct
Rename 'channel.gc.cnt' to 'channel.gc'
2019-12-13 18:04:54 +08:00
Feng Lee d193b5fa0d Rename 'channel.gc.cnt' to 'channel.gc' 2019-12-11 20:39:51 +08:00
Feng Lee d1c3dec730 Optimize emqx_session and add more test cases 2019-12-11 13:44:52 +08:00
zhouzb e30c0ac31d Change log level for existing metric 2019-12-10 17:20:21 +08:00
zhouzb ec2f758c9f Use erlang:system_time/1 2019-12-10 09:25:39 +08:00
JianBo He 08e234f61e Fix typo 2019-12-10 09:24:33 +08:00
Feng Lee 0f9f1258b6 Improve the emqx_message module and add more test cases
- Add 'emqx_message:clean_dup/1' function
- Clean dup flag before publishing a message
- Add more test cases for emqx_message module
2019-12-10 09:22:38 +08:00
Feng Lee cd94ba71b4 Remove the 'try' ... 'catch' 2019-12-10 09:01:55 +08:00
Feng Lee 0c377c67cd Use 'erlang:system_time' to replace 'os:timestamp' (#3088)
Use 'erlang:system_time/1' to replace 'os:timestamp/0'
2019-12-09 16:27:25 +08:00
zhouzb dace882667 Fix will message 2019-12-07 17:06:22 +08:00
Feng Lee dc3e7dc21c Ignore the expired messages 2019-12-07 16:51:20 +08:00
Feng Lee bbcd2bffc5 Improve the session module (#3082)
Improve the session module
2019-12-07 15:54:02 +08:00
zhouzb 32500685a1 Export emqx_cm:kick_session/2 2019-12-07 13:35:55 +08:00
zhouzb 5b949fda2c Add emqx_cm:kick_session/1 2019-12-07 13:31:33 +08:00
Feng Lee 9c3273a2c6 Improve the process of handling MQTT control packets (#3079) 2019-12-06 19:51:06 +08:00
tigercl 98b109b6b2
Merge pull request #3074 from emqx/emqx_desc
Add emqx.app.src.script
2019-12-05 18:01:24 +08:00
turtled dceb087039 Format code 2019-12-04 13:54:59 +08:00
turtled 4b59db62fa Optimize caps 2019-12-04 13:52:01 +08:00
turtled 691c6aa182 Add emqx.app.src.script 2019-12-04 13:50:31 +08:00
turtleDeng a540958846 Add mqtt.strict_mode configuration (#3069)
Add mqtt.strict_mode configuration
2019-12-04 10:54:52 +08:00
zhouzb 8bf06b9c63 Fix typo 2019-11-23 10:53:27 +08:00
tigercl f44b8ce607
Avoid emqx crashes due to auth plugins (#3047)
Avoid emqx crashes due to auth plugins
2019-11-23 10:11:48 +08:00
zhouzb 790c729b1f Optimize code 2019-11-21 16:26:50 +08:00
JianBo He d7ddc406fa Fix ConnInfo of client.connected hook 2019-11-21 15:01:57 +08:00
Feng Lee 1af1fc4f6a Fix the check of limiter 2019-11-18 11:51:58 +08:00
Feng Lee 39dbb03629 Fix the 'undefined function' call 2019-11-18 11:11:20 +08:00
zhouzb c9963b1df5 Replace esockd_net with inet 2019-11-18 10:58:15 +08:00
tigercl 6288cd1345
Merge branch 'develop' into bump-version 2019-11-18 10:53:33 +08:00
tigercl d793c4256f
Merge pull request #3034 from emqx/rm-vm-module
Improve the emqx_vm module and update test cases
2019-11-18 10:51:54 +08:00
tigercl b10cd85ba3
Merge pull request #3033 from emqx/flapping2
Optimize flapping and banned modules
2019-11-18 10:50:35 +08:00
tigercl 2ad701361d
Merge pull request #3031 from emqx/more_test_cases
Add more test cases
2019-11-18 10:49:56 +08:00
Feng Lee 4935ba11a8 Upgrade deps to ekka v0.7.0 and esockd v5.6.0 2019-11-18 10:40:53 +08:00
zhouzb 73275a2b4d Replace inflight with inflight_cnt in STATS_KEYS 2019-11-18 10:24:23 +08:00
Feng Lee 17332b0465 Improve the emqx_vm module and update test cases 2019-11-14 10:40:55 +08:00
Feng Lee d3107facf9 Validate packet id if strict mode. 2019-11-14 09:46:56 +08:00
zhouzb 2fb4d66496 Optimize flapping and banned modules 2019-11-14 09:37:37 +08:00
zhanghongtong 1072536382 Add more test cases for emqx_sup 2019-11-13 18:30:02 +08:00
zhanghongtong b22a1a87ba Add more test case for emqx_plugins 2019-11-09 21:26:15 +08:00
zhanghongtong f1ae430d43 Add more test cases for emqx_sys 2019-11-08 17:01:10 +08:00
terry-xiaoyu df3d7b628b Update emqx_ws_connection for clientinfo 2019-11-01 21:36:30 +08:00
terry-xiaoyu 3cc2bf2bfa Merge branch 'develop' into make_test_cases_pass 2019-11-01 20:05:52 +08:00
zhouzb 0be06a93d6 Fix test cases 2019-11-01 18:38:30 +08:00
terry-xiaoyu d946848d42 Improve testcases for emqx_logger 2019-11-01 18:21:46 +08:00
tigercl 1a901942f7
Merge pull request #3007 from emqx/improve-connection
Improve the 'connection', 'channel' and 'zone' modules
2019-11-01 16:40:20 +08:00
tigercl 81a507c6fa
Merge pull request #3012 from emqx/add_more_test_cases
Add more test cases
2019-11-01 16:40:00 +08:00
tigercl b3731aaff4
Merge pull request #3010 from emqx/test_cases_zhou
Add test cases and fix bugs
2019-11-01 16:29:00 +08:00
zhouzb c5ad674dd7 Add test cases and fix bugs 2019-11-01 15:48:28 +08:00
Feng Lee 2b1b58fc66 Add the new 'emqx_limiter' module 2019-11-01 08:10:58 +08:00
Feng Lee 6f30dca4ba Add more option APIs 2019-11-01 08:10:26 +08:00
Feng Lee d256387cee Ensure the 'inc_sent/1', 'inc_recv/1' to return 'ok' 2019-11-01 08:09:45 +08:00
Feng Lee 30adfc18e6 Remove 'gc_state' and 'pub_stats' from channel's state 2019-11-01 08:08:38 +08:00
Feng Lee 605a03453e Remove the 'emqx_time' module and use 'erlang:system_time/1' 2019-11-01 08:07:34 +08:00
Feng Lee 223163d5b9 Remove the 'emqx_oom' module 2019-11-01 08:00:35 +08:00
Feng Lee 4c9dda105f Add 'active_n' option for WebSocket listener 2019-11-01 08:00:11 +08:00
zhanghongtong 971a361ea9 Add more test cases for emqx_logger and fix bug for emqx_logger 2019-10-29 14:27:47 +08:00
terry-xiaoyu 3405dbaf5c Ordered messaging via multiple gen_rpc clients 2019-10-28 21:01:53 +08:00
terry-xiaoyu f7d3c01308 Merge branch 'develop' into clean_acl_cache 2019-10-28 18:02:41 +08:00
terry-xiaoyu c1d768ff74 Add API for clean and get acl cache 2019-10-28 17:53:53 +08:00
Feng Lee ebef0ec554 Add zone_options module 2019-10-28 07:51:09 +08:00
张奇怪 c713d619da
Add more test cases (#2992)
* 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
2019-10-24 15:41:26 +08:00
turtled 1dfbe8e166 Fix WS badmatch 2019-10-22 09:11:42 +08:00
Feng Lee fca7a7e761 Merge branch 'connection-test-using-meck' into develop 2019-10-21 19:53:53 +08:00
terry-xiaoyu cb77b229b8 Add testcase for emqx_logger_formatter 2019-10-21 18:35:32 +08:00
Feng Lee 7117dde879 Add more test cases for connection, channel and session modules 2019-10-21 17:14:50 +08:00
Feng Lee 26eab630b3 Add test cases for emqx_channel module 2019-10-20 19:20:38 +08:00
Feng Lee aecda09b9a Add more test cases 2019-10-19 20:18:34 +08:00
Feng Lee cd4adbada0 Add more test cases for connection, channel and session modules 2019-10-18 18:53:31 +08:00
Feng Lee 53dda48833 Fix the 'function_clause' error when session is undefined 2019-10-14 17:01:41 +08:00
Feng Lee a1877f3f42 Return the '{enter, connected}' event first 2019-10-14 13:04:49 +08:00
Feng Lee 6233aa7d46 Ensure the 'conn_state' be 'disconnected' after socket closed 2019-10-12 19:14:33 +08:00
Feng Lee 932821360f Merge branch 'new-connection-module' into develop 2019-10-12 17:08:48 +08:00
Feng Lee cce0dbd3cf Improve the connection, ws_connection and channel modules 2019-10-12 17:05:37 +08:00
terry-xiaoyu 47a192ee34 Avoid process crash report for arbitrary exit reason 2019-10-12 14:48:39 +08:00
terry-xiaoyu ebea3cc392 Defend the ssl upgrade failure 2019-10-12 09:34:28 +08:00
zhouzb 7512d6cb03 Check topic level for publish packet and optimize the handling of rap 2019-10-12 09:33:47 +08:00
Feng Lee 0c37c65a59 Add a new type 'sockstate/0' 2019-10-10 13:59:34 +08:00
Feng Lee e718fa8249 Rewrite the 'emqx_connection' module using a raw erlang process 2019-10-08 17:59:11 +08:00
zhouzb ddd68e600d Fix missing cases 2019-09-29 15:32:53 +08:00
Feng Lee fe2a72c664 Add 'state' field to channel info 2019-09-29 11:47:31 +08:00
Feng Lee 977b551bbf Fix the test cases for session, channel and connection modules 2019-09-29 10:53:59 +08:00
Feng Lee 8ab682151d Improve the connection and channel modules
- Rename the 'client_id' field to 'clientid'
- Support publish stats in channel module
- Update test cases for frame and channel modules
2019-09-29 10:22:02 +08:00
Feng Lee 7b1a80c265 Rename 'mailbox_len' to 'message_queue_len' 2019-09-27 20:26:54 +08:00
Feng Lee 89b03eb9a6 Add function specs 2019-09-24 17:08:06 +08:00
Feng Lee 609f442ea9 Add function 'get_counters/1' 2019-09-24 17:07:32 +08:00
Feng Lee 20ddd498fc Rename the 'client_id' field to 'clientid' 2019-09-24 17:06:25 +08:00
Feng Lee 98b7e3d948 Rename the type 'client()' to 'client_info()'
- Rename tye type 'client()' to 'client_info()'
- Rename the 'client' field of channel to 'client_info'
- Fix the function specs
2019-09-21 15:27:05 +08:00
terry-xiaoyu eb0826ef3f Fix testcases for new object field protocol 2019-09-21 12:37:08 +08:00
terry-xiaoyu 18edf5cec3 Add protocol in client object 2019-09-21 12:20:20 +08:00
terry-xiaoyu ab9d7232a9 Reset peerport 2019-09-20 22:57:01 +08:00
terry-xiaoyu 464746e9a5 Add peerport 2019-09-20 22:42:07 +08:00
terry-xiaoyu 0bd69ba059 Fix connack reason code when crash 2019-09-20 22:30:16 +08:00
terry-xiaoyu b29ceb9f6b Fix connack reason code when crash 2019-09-20 22:27:02 +08:00
terry-xiaoyu d0908bc70f Improve the pipeline error msg 2019-09-20 21:40:15 +08:00
terry-xiaoyu 9e1f1b22c3 Fix typo 2019-09-20 21:35:02 +08:00
terry-xiaoyu 1decab9369 Fix channel crash before CONNECT 2019-09-20 21:30:18 +08:00
zhouzb db1cf4469b Fix crash 2019-09-20 20:27:08 +08:00
tigercl b72a82e50b
Merge pull request #2919 from emqx/fix-test-cases
Add 'unregister_channel/1' function and test cases
2019-09-20 19:57:47 +08:00
Feng Lee d0a8086d73 Add 'unregister_channel/1' function and test cases 2019-09-20 19:42:59 +08:00
terry-xiaoyu 4d214fb6e2 Fix session not saved after maybe_resume_session 2019-09-20 18:28:44 +08:00
zhouzb f0a1ffc3b1 Fix test case 2019-09-20 17:58:31 +08:00
Feng Lee 6aac73f51f Fix the test case 't_handle_disconnect' 2019-09-20 16:48:21 +08:00
Feng Lee a9daa3c821 Fix the merge conflicts 2019-09-20 16:38:02 +08:00
terry-xiaoyu b5c9def06a Add testcases for print and usage 2019-09-20 16:18:24 +08:00
Feng Lee 1a3261b186
Merge branch 'develop' into remove-protocol-module 2019-09-20 16:17:44 +08:00
zhouzb 24bfaa768d Call emqx_flapping:detect and generate alarm when flapping is detected 2019-09-20 15:01:51 +08:00
zhouzb a9dd94b2b5 Improve mechanism of waiting for session to expire 2019-09-20 15:01:51 +08:00
terry-xiaoyu bd33441720 Fix the type specs for cmd usage 2019-09-20 14:55:11 +08:00
Feng Lee 3202ed2392 Improve the 'channel' module and add more test cases
- Rename the 'Client' field to 'ClientInfo'
- Remove the 'expiry_interval' from session record
- Add more test cases for emqx_zone module
- Add more test cases for emqx_banned module
- Add more test cases for emqx_message module
- Remove 'sockname', 'conn_mod' fields from type 'client'
2019-09-20 14:38:16 +08:00
Feng Lee 81e2f47126 Add test cases for emqx_ctl module 2019-09-20 13:47:05 +08:00
Feng Lee 3d6b96d321 Add function 'get_flags/1' for test 2019-09-19 11:19:10 +08:00
Feng Lee 65cb9dbf38 Add test cases for 'reason/1' 2019-09-19 11:16:13 +08:00
Feng Lee 3705f4f929 Rewrite the test cases for extended modules 2019-09-19 11:04:29 +08:00
Feng Lee 1d429dad8d Update the 'attrs/1' and 'handle_timeout/3' functions 2019-09-18 20:01:22 +08:00
Feng Lee 981afd38e3 Rewrite the 'presence' extended module 2019-09-18 19:58:12 +08:00
Feng Lee 8404fce6a6 Remove the function 'update_expiry_interval/2' 2019-09-18 19:49:34 +08:00
Feng Lee a313d1c722 Improve the 'open_session/3' API 2019-09-18 19:48:55 +08:00
Feng Lee 94c324d7a3 Rename 'get|set_property' fuctions to 'get|set' 2019-09-18 19:47:44 +08:00
Feng Lee cc79802d6c Add function 'get_caps/3' 2019-09-18 19:46:18 +08:00
Feng Lee ad7e0ae436 Use 'peerhost' to replace 'peername' 2019-09-18 19:44:28 +08:00
Feng Lee c8acd55afa Export type 'opts/0' 2019-09-18 19:19:42 +08:00
Feng Lee 50f392b295 Add more functions 2019-09-18 19:18:56 +08:00
Feng Lee 00f3a2f939 Use 'peerhost' to replace 'peername' 2019-09-18 19:17:30 +08:00
zhouzb decdce2ae2 Fix unused variable 2019-09-16 18:54:34 +08:00
zhouzb 600cd11f1f Rename connection to conninfo 2019-09-16 17:22:50 +08:00
zhouzb 1667cbd359 Fix test cases 2019-09-16 16:05:06 +08:00
tigercl fc553b8cee
Merge pull request #2803 from emqx/fix_msg_expiry
Fix Message-Expiry-Interval not working
2019-09-16 14:45:22 +08:00
Feng Lee 4764a7707c Rewrite the emqx_packet module and improve channel pipeline (#2903)
Add use_username_as_clientid/1 function and Improve function 'pipeline/3'
2019-09-16 14:17:36 +08:00
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
Shawn 59309e6c11
Add print and usage APIs for CLI (#2893) 2019-09-12 09:35:05 +08:00
Feng Lee 80621ec9be Fix the test cases for emqx_banned, emqx_flapping modules
- Remove the 'is_enabled/1' function of 'emqx_banned' module
- Remove the 'is_enabled/1' function of 'emqx_flapping' module
- Add 'enable_acl/1', 'enable_banned/1' and 'enable_flapping_detect/1'
2019-09-11 09:14:58 +08:00
Feng Lee fa516626a6 Inlining is enabled for encode, decode functions. 2019-09-11 09:13:42 +08:00
Feng Lee 594153c0fb Merge branch 'boot' into develop 2019-09-10 16:26:20 +08:00
Feng Lee 2bf951d953 Fix the spec of function 'is_enabled/1' 2019-09-10 16:24:38 +08:00
Feng Lee a3daa533e7 Add a test case for the new flapping module 2019-09-10 16:20:56 +08:00
Feng Lee 0a1679b122
Implement a new flapping module (#2884) 2019-09-10 15:21:08 +08:00
Feng Lee 88321fe6fe Remove the emqx_config module
- Remove the emqx_config module
- Move get_env/1, get_env/2 to emqx module
2019-09-09 10:18:10 +08:00
Feng Lee 6972cbb36e Fix the operator precedence bug 2019-09-06 19:04:11 +08:00
Feng Lee b97f04ceae Add emqx_boot module 2019-09-06 17:37:50 +08:00
Feng Lee 6e18f8543d Add emqx_boot module 2019-09-06 17:36:13 +08:00
zhouzb 5a3645c97e Remove proto_ver field stored in the headers of message 2019-09-06 14:51:52 +08:00
Michael Schmidt 3038bd4570 Add support for logger per module filtering (#2873)
Add mfa to the meta data to suppor the Erlang Logger's per module / per app filtering
2019-09-06 11:03:47 +08:00
zhouzb 066763248c Fix dup flag 2019-09-05 18:35:29 +08:00
zhouzb de44a89c21 Fix the issue that protocol is undefined 2019-09-05 18:28:17 +08:00
terry-xiaoyu 1e4c51f080 Send DISCONNECT on packet parse error 2019-09-05 18:16:15 +08:00
zhouzb cc4ee065a4 Remove debug print 2019-09-05 16:16:19 +08:00
terry-xiaoyu 983973c841 Fix set_chan_stats incorrect 2019-09-05 15:59:18 +08:00
Feng Lee 451f0451ce Add type/1, qos/1 functions 2019-09-05 15:00:54 +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
tigercl 811e85f8b7
Merge pull request #2841 from emqx/init_stats
Set stats at connection time
2019-09-05 14:03:51 +08:00
Feng Lee 2d6c7e41a5 Remove emqx_cli module 2019-09-02 09:04:34 +08:00
Feng Lee 62f0f0ccbc Add more test cases for 'emqx_misc' module 2019-08-28 14:29:44 +08:00
Feng Lee 08ab350fec Move the 'pipeline' function to 'emqx_misc' module 2019-08-28 14:29:44 +08:00
GilbertWong 783e29d6f7 Add test case for emqx_mod_rewrite 2019-08-28 11:19:51 +08:00
Feng Lee a4e9142979 Updat app file 2019-08-27 09:27:25 +08:00
zhouzb 98072dd3d1 Set stats at connection time 2019-08-26 16:43:08 +08:00
turtled 29d49b4073 Fix get connected_at is undefined 2019-08-23 20:37:04 +08:00
zhouzb 5cfd8b74bc Fix a bug that crash when protocol is undefined 2019-08-23 17:29:48 +08:00
zhouzb 9c171f5d9c Fix a bug that session terminates immediately when received DISCONNECT packet 2019-08-23 16:08:26 +08:00
zhouzb 970d243d94 Fix function clause 2019-08-23 15:23:00 +08:00
tigercl 7151ae9823
Merge pull request #2836 from emqx/fix-discard
Fix case clause error
2019-08-23 15:18:24 +08:00
Feng Lee 710302f377 Fix case clause error 2019-08-23 14:52:11 +08:00
tigercl ebc1bd77a9
Send the will message immediately when the network connection is closed by the client (#2834)
Send the will message immediately when the network connection is closed by the client
2019-08-23 14:41:52 +08:00
Feng Lee 738145677a Handle the 'discard' cast. 2019-08-23 14:31:33 +08:00
tigercl 9f7cc80c1a
Merge pull request #2833 from emqx/update_code
Update emqx_channel.erl
2019-08-23 14:09:42 +08:00
Feng Lee 82b9a7c301 Improve session takeover (#2831)
Implement the session takover/resumption across nodes
2019-08-23 14:09:00 +08:00
zhouzb 44d53ecb33 Update emqx_channel.erl 2019-08-23 13:48:17 +08:00
zhouzb f3a92f35f6 Handle will message correctly 2019-08-23 13:37:35 +08:00
zhouzb cff120c6d0 Handle session expiry interval correctly 2019-08-23 13:37:35 +08:00
Zhiwei Yu 8710df31b2 Monitor cluster partition event (#2814) 2019-08-23 09:42:55 +08:00
Feng Lee c69a2b1b48 Ensure session expiration (#2825)
Ensure session expiration
2019-08-23 09:35:29 +08:00
Feng Lee 41e9dad70a Rename `reason` field to `stop_reason` 2019-08-22 23:24:16 +08:00
zhouzb 7454e46934 Fix compile error 2019-08-22 16:59:13 +08:00
Feng Lee 8b03371a4a Improve the keepalive, connection, channel and session modules (#2813) 2019-08-22 16:38:25 +08:00
Mousse bf942e4bec Handle the retained flag correctly (#2811)
Handle the retained flag correctly
2019-08-22 16:21:27 +08:00
tigercl 201428279b
Merge pull request #2817 from emqx/test_emqx_config
Remove redundant code and add test case
2019-08-22 16:13:50 +08:00
GilbertWong 3f20bcf58f Relace emqx_client with emqtt 2019-08-22 14:27:29 +08:00
zhouzb 94c56b5e31 Remove redundant code and add test case 2019-08-21 14:12:34 +08:00
tigercl 749ef823ab
Refix code about mqtt spec (#2806)
Refix code about mqtt spec
2019-08-19 10:50:52 +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 52b2f31ced Merge branch 'improve-channel-design-again' into develop 2019-08-17 14:09:26 +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
tigercl c1fd5f89f1 Make codes compliance with mqtt protocol specifications (#2790)
* Make codes compliance with mqtt protocol specifications

* Fix test case

* Remove emqx_protocol:puback/4
2019-08-17 09:15:43 +08:00
terry-xiaoyu fa1adf5cfb Fix Message-Expiry-Interval not working 2019-08-16 18:27:22 +08:00
tigercl 2e26cd244a Improve test coverage (#2799)
* Improve test coverage

* Improve test coverage for emqx_cm

* Improve test coverage for emqx_cm_registry

* Fix emqx_client_SUITE
2019-08-16 18:25:49 +08:00
Feng Lee d63eccd8b8 Add test cases for emqx_keepalive module (#2784)
* Improve the keepalive module
2019-08-16 18:24:39 +08:00
Gilbert 79744af681 Wrapper proper test cases into common test cases (#2785)
* Wrapper proper test cases into common test cases

* Improve test cases for reason code module (#2789)

* Split 3 proper tests into 3 ct cases

* Improve test cases for client, rpc and request-response

* Add psk suites to increase coverage

* Add sys test cases
2019-08-16 18:07:12 +08:00
JianBo He 8e401968f2 Add testcase for emqx_mod_sup 2019-08-16 17:48:37 +08:00
Shawn b2ddcb26e2
Testcase logf (#2800)
* Add test cases for logger formatter

* Remove the unregister API
2019-08-16 15:11:38 +08:00
Feng Lee 444972968f Improve emqx_mqtt_props module and add test cases 2019-08-12 14:29:38 +08:00
周子博 c2cd43ee18 Fix attrs 2019-08-10 00:37:45 +08:00
terry-xiaoyu 0c24bfd78c Make emqx_tracer more reliable 2019-08-09 19:59:39 +08:00
周子博 f6d6f7f04d Fix test case 2019-08-09 19:45:43 +08:00
terry-xiaoyu 77616f4721 Add hook client.disconnected 2019-08-09 19:25:14 +08:00
terry-xiaoyu a19777c2e6 Add hook message.acked 2019-08-09 19:12:56 +08:00
turtled a93f8c6788 Fix auth fail 2019-08-09 17:37:55 +08:00
turtled 31cc446818 Mountpoint support %c and %u 2019-08-09 16:54:49 +08:00
turtled 91a8dbda56 Fix conflicts 2019-08-09 16:41:11 +08:00
周子博 d8bcb1b26f Don't check cpu util on Alpine that uses libc-musl 2019-08-09 16:10:30 +08:00
GilbertWong 6e0a269ff6 Wrap `os:type` for cpu:sup call 2019-08-09 16:04:38 +08:00
Feng Lee 439c481e35 Remove the trap_exit process_flag (#2737) 2019-08-09 16:02:50 +08:00
Shawn 68bf72ce04 Fix crashes when auth failed (#2736) 2019-08-09 16:02:04 +08:00
terry-xiaoyu cca725db5f Add specs for emqx_logger 2019-08-09 15:47:20 +08:00
Feng Lee 3032731a2d Publish will msg when abnormal terminate 2019-08-09 15:28:47 +08:00
Feng Lee 03744ead30 Ensure the 'CONNACK' and 'DISCONNECT' packets delivered. 2019-08-09 15:09:17 +08:00
Feng Lee 52a85d9bb9 Export name/1 2019-08-09 15:09:17 +08:00
Feng Lee a324965240 Add more test cases for emqx_protocol module 2019-08-09 14:29:49 +08:00
Gilbert abb4b07665
Add session proper test cases (#2768)
* Add session proper test cases
* Remove useless mockers
2019-08-09 14:15:34 +08:00
GilbertWong 61ee889113 Fix client bug 2019-08-09 13:40:07 +08:00
Feng Lee 916afc1c74 Add test cases for emqx_protocol module
- Add emqx_session:info/2 for unit tests
- Add emqx_protocol:set/3 for unit tests
- Fix the `check_sub/3` of emqx_mqtt_caps
2019-08-09 11:33:52 +08:00
Feng Lee a2d5b834da Improve emqx_pmon module and add more test cases 2019-08-08 22:42:45 +08:00
Feng Lee 6513a32d37
Merge pull request #2766 from emqx/improve-mqtt-caps-module
Improve mqtt caps module
2019-08-08 22:35:32 +08:00
Feng Lee f70da696f0 Fix the badmatch error 2019-08-08 22:33:40 +08:00
GilbertWong 1707c7a7b7 Remove replayq from app.src list 2019-08-08 17:08:19 +08:00
周子博 0d65deb9d3 Fix not registering channels in time 2019-08-08 16:59:17 +08:00
Feng Lee bd061415c9 Rewrite the emqx_mqtt_caps module and add test cases
- Rename `mqtt_retain_available` to `retain_available`
- Rename `mqtt_wildcard_subscription` to `wildcard_subscription`
- Rename `mqtt_shared_subscription` to `shared_subscription`
- Add `emqx_zone:unset_env/2` API for unit test
2019-08-08 14:11:26 +08:00
Feng Lee bfd027cf8b Rewrite the mqtt_caps module 2019-08-07 14:01:50 +08:00
Gilbert 96b341fde5
Add proper tests for base62 (#2761)
* Add proper tests for base62

* Delete useless comment
2019-08-07 09:24:03 +08:00
Feng Lee f60f127681 Improve the moudules and fix the bugs found in new test cases
- Fix the bug that emqx_mountpoint:unmount/2 will throw exception
- Add emqx_banned:info/1 for test cases
- Rename macro TRIE in emqx_trie module to TRIE_TAB
- Rename macro TRIE_NODE in emqx_trie module to TRIE_NODE_TAB
- Rename macro ROUTE in emqx_router module to ROUTE_TAB
2019-08-06 09:05:55 +08:00
Feng Lee 4afa02ee48 Update all the test cases 2019-08-06 09:04:37 +08:00
Feng Lee f8e28e39ed Improve the channel modules and fix the extension mods 2019-08-02 18:04:38 +08:00
Feng Lee 32795321f5 Improve the rewrite mod using the new hooks 2019-08-02 11:14:42 +08:00
Feng Lee cf9caf3c32 Add conn/0 type 2019-08-02 11:14:42 +08:00
Feng Lee 2fdda99d6d Improve the pipeline design of protocol and session 2019-08-02 11:14:42 +08:00
周子博 ef9cbe51eb Fix conflict 2019-08-02 10:41:46 +08:00
Feng Lee c95a89ed1e Merge branch 'nchannel' into develop 2019-07-31 14:03:48 +08:00
Feng Lee 0a6468cf48 Introduce the 'pipeline' design pattern
- Introduce the 'pipeline' design pattern in emqx_protocol module
- Reame the '{dispatch, ...' to '{deliver, ...' in emqx_broker module
- Rename type 'credentials' to 'client'
2019-07-31 08:09:47 +08:00
Feng Lee b32156bd68 Rename the type 'credentials' to 'client' 2019-07-31 08:08:11 +08:00
Feng Lee 41dfbd4165 Add 'packets.pubrec.inuse' counter 2019-07-30 19:12:42 +08:00
Feng Lee c880668419 Register channel in this module 2019-07-30 19:11:21 +08:00
Feng Lee 51fb4e33d6 Rename 'Credentials' to 'Client' 2019-07-30 19:10:38 +08:00
terry-xiaoyu 20a7ed6f53 RPC batch 2019-07-29 09:35:06 +08:00
Feng Lee c55ada3526 Improve the types 2019-07-27 23:24:38 +08:00
Feng Lee d99c9daf76 Replace credentials with client 2019-07-27 23:22:02 +08:00
terry-xiaoyu b0e2b7db0c Support inter-node messages via RPC cast 2019-07-27 12:59:07 +08:00
terry-xiaoyu 11fdf101f0 Configurable rpc client number 2019-07-26 15:13:58 +08:00
Feng Lee 32b2a01d68 Fix function_clause error and improve ws channel 2019-07-26 00:18:25 +08:00
Feng Lee 64148ac0e8 Improve the 'info/1', 'attrs/1' and 'stats/1' APIs 2019-07-25 09:26:36 +08:00
Feng Lee b4a0a1c228 Fix whitespace 2019-07-25 09:26:02 +08:00
Feng Lee 5b3a61b799 Merge the connection and session tabs into channel tab 2019-07-25 09:25:45 +08:00
Feng Lee a0a2375810 Update the .app file 2019-07-25 09:25:00 +08:00
Feng Lee 2de4bb0b8f Improve the channel modules and add 'attrs/1' API 2019-07-25 09:24:10 +08:00
Feng Lee c091e89796 Remove the unnecessary include/emqx_client.hrl 2019-07-23 10:56:14 +08:00
Feng Lee 6b84eb0595 Rewrite the channel, protocol and session modules. 2019-07-22 17:08:53 +08:00
terry-xiaoyu 0569388f0f Fix websocket still send willmsg even after disconnect is received 2019-07-20 19:02:49 +08:00
terry-xiaoyu 4559b5023e Fix heartbeat interval 2019-07-20 16:20:53 +08:00
terry-xiaoyu 721e7c4804 Fix session termiated without ws_channel 2019-07-20 14:24:15 +08:00
terry-xiaoyu 0c54d899da Trap and handle exit in channel and ws_channel 2019-07-20 13:19:13 +08:00
Gilbert 05b660ff50 Unlink session when exit message has been forwarded to session (#2703)
* Unlink session when exit message has been forwarded to session

* Readjust possition of emqx_protocol:session
2019-07-20 13:05:34 +08:00
GilbertWong eb68ce77b6 Fix the ws channel terminating crash when session pid is undefined 2019-07-19 17:36:50 +08:00
GilbertWong 391e39c3b6 Disable the useless error log info 2019-07-19 17:36:50 +08:00
GilbertWong 0c14484b0a Disable the useless error log info 2019-07-19 17:36:50 +08:00
GilbertWong 953d320667 Implement better websocket exit mechanism 2019-07-19 17:36:50 +08:00
terry-xiaoyu 86333802b9 Add configuration for sys_heartbeat 2019-07-19 17:33:24 +08:00
GilbertWong 4603ea17ef Better gen_rpc performance 2019-07-19 17:31:15 +08:00
GilbertWong eb7ae13ae9 Better exit reason in websocket channel 2019-07-16 01:33:15 +08:00
GilbertWong 1fc0f61fbb Fix the websocket normal exit bug 2019-07-16 01:09:42 +08:00
Feng Lee 7b27d49a40 Add new metric 'channel.gc.cnt' 2019-07-14 08:59:38 +08:00
terry-xiaoyu 7472e531b1 Remove log handler for alarms 2019-07-11 13:27:03 +08:00
terry-xiaoyu 1bf68f4807 Change clear alarms to info log 2019-07-11 11:15:23 +08:00
GilbertWong bf89646d93 Fix typo 2019-07-11 09:43:52 +08:00
GilbertWong 234037aee1 Fix will message mechanism for websocket channel 2019-07-11 09:43:52 +08:00
GilbertWong c13e194838 Fix the check_subacl bug when enable_acl is set to false 2019-07-11 09:25:20 +08:00
terry-xiaoyu 5867b2e763 Fix idle_timeout crash 2019-07-11 09:17:23 +08:00
terry-xiaoyu 6ab9527603 Optimize to_map for performance 2019-07-05 23:14:27 +08:00
Gilbert 70be888f3b Compat windows (#2665) 2019-07-05 23:10:13 +08:00
周子博 61d64cbb83 Fix the issue that emqx_session:attrs/1 returns wrong value 2019-07-05 22:54:57 +08:00
Feng Lee f4a753f683 Remove the debug print of batch deliver 2019-07-02 14:50:13 +08:00
Feng Lee 8c37ea3f38 Fix conflict 2019-07-02 14:02:42 +08:00
Feng Lee 42da51e1c5 Implement batch delivery for the new channel design
- Implement a new emqx_channel module
- Improve the emqx_frame:serialize/2 API
- Improve the emqx_connection, emqx_ws_connection modules
2019-07-02 13:40:52 +08:00
Feng Lee 177dc44155 Define 'Otherwise' macro 2019-07-02 13:39:23 +08:00
周子博 3ad5700442 Support getting the history of alarms 2019-06-29 12:38:57 +08:00
terry-xiaoyu 96fff39535 Change default logger level to warning 2019-06-28 21:34:21 +08:00
terry-xiaoyu 0e2e4e73ca Clean staled sesssions 2019-06-26 20:04:32 +08:00
Gilbert 9df6345a6c Remove bridge functions from emqx (#2652)
* Remove bridge functions from emqx
2019-06-26 19:33:17 +08:00
tradingtrace 0b116bc208 Fix the massages order when batch dispatching 2019-06-26 19:32:15 +08:00
Feng Lee 9ee0a4d171 Fix the function_clause error when publishing QoS2 message 2019-06-25 17:35:58 +08:00
Feng Lee 67b7266438 Rename TimerInterval to Interval 2019-06-25 15:58:09 +08:00
Feng Lee f32a415a83 Merge branch 'channel3' 2019-06-25 15:55:31 +08:00
Feng Lee 4974eab20e Improve the channel design 2019-06-25 14:53:45 +08:00
Feng Lee c4eb283517 Add spec for validate/1 function 2019-06-25 14:50:51 +08:00
Feng Lee 242a1ae453 Use emqx_mqtt:qos() type 2019-06-25 14:47:42 +08:00
Feng Lee 72331d8ad0 Move emqx_mqtt_types module to emqx_mqtt 2019-06-25 14:46:21 +08:00
Feng Lee fb54fe0fad Improve export_type attr 2019-06-25 14:45:23 +08:00
Feng Lee 795fe4e0bc Add 'PUBLISH_PACKET(QoS, Topic, PacketId)' macro 2019-06-25 14:29:26 +08:00
Gilbert 475cabde4d Fix issue#2619 (#2646)
* Fix issue#2619
Prior to this change, websocket connection would not be disconnected
when dataframe type is other frametype. However, in mqtt spec, it
shoud be disconnected.

This change fix this inconsistent behaviour with mqtt 5.0
2019-06-21 21:21:49 +08:00
turtled 481458d8ec Add plugin type 2019-06-21 19:52:53 +08:00
tigercl 0c7c4ee417 Using fixed topic for system message of alarm (#2647)
* Using fixed topic for system message of alarm
2019-06-21 19:51:58 +08:00
tigercl 37eef7b72a Add 'auth.mqtt.anonymous' metric (#2631)
* Add 'auth.mqtt.anonymous' metric
2019-06-21 19:21:26 +08:00
Gilbert 138d7727fa
Compact windows platform which has no cpu_sup util function. (#2629)
* Compact windows platform which has no cpu_sup util function.

* Fix wrong os type clause

* Do not start timer when platform is windows
2019-06-20 11:45:44 +08:00
Gilbert 1d23d7de86
Optimize test workflow (#2642)
* Optimize test suites workflow

* Better format of makefile

* Fix protocol suite

* Add emqx_access_SUITE
2019-06-20 11:44:44 +08:00
GilbertWong bcae452e42 Fix the flapping bug
Prior to this change, the banned until value will not be set
correctly because of wrong spell of config entry name .

This change fix this bug
2019-06-20 10:59:42 +08:00
GilbertWong ffbb598a73 Increase time precision for emqx_mod_presence 2019-06-20 09:50:05 +08:00
Feng Lee 3877c4db1a Merge branch 'channel2' into channel3 2019-06-18 16:49:26 +08:00
Feng Lee 7774b85f81 Implement the channel architecture 2019-06-18 15:03:51 +08:00
terry-xiaoyu 09dd65b9fa Add logger header validation 2019-06-18 14:37:32 +08:00
terry-xiaoyu 7092748266 Improve log messages using logger header 2019-06-18 14:37:32 +08:00
terry-xiaoyu c64751a53c Support module level logger header 2019-06-18 14:37:32 +08:00
Feng Lee 21162f88b8 Update copyright 2019-06-18 14:27:06 +08:00
Feng Lee d065847665 Remove session record 2019-06-16 10:28:23 +08:00
terry-xiaoyu 3f1b788fe8 Remove unused PSK TAB macro 2019-06-14 16:58:46 +08:00
GilbertWong 19822c15bd Add websocket_info to match {stop, Reason} msg 2019-06-14 16:22:57 +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
turtleDeng 76525cc703
Fix acl deny action logic (#2613) 2019-06-12 15:49:18 +08:00
tigercl 3462bbd619 Fix retain in will message (#2607)
* Fix retain in will message

* Only handle retain available flag in MQTT v5
2019-06-12 15:43:52 +08:00
Feng Lee de978d4771 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
2019-06-12 10:31:44 +08:00
Feng Lee d386b27e8a Adopt channel architecture and improve the MQTT frame parser 2019-06-11 23:18:38 +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
turtled f46205daff Restart mnesia application 2019-06-05 11:50:09 +08:00
Gilbert Wong f3fcd16dee Fix wrong default value in protocol module 2019-06-03 16:25:04 +08:00
Gilbert Wong e7cd32edb7 Update esockd deps and fix compile warning 2019-05-31 15:21:59 +08:00
Gilbert Wong 47f9d0e90f Adjust format 2019-05-31 11:16:50 +08:00
Gilbert Wong 365832f945 Use new ranch api to elimate warning log for deprecated apis 2019-05-31 11:16:50 +08:00
Feng Lee 9715234626 Optimize the emqx_zone module using persistent_term
- Don't reload the zone options for updating persistent_term is
expensive
- Use '{?MODULE, Zone, Key}' as the key to avoid name collision
2019-05-31 08:53:42 +08:00
terry-xiaoyu be7de756c6 Stop alarm before emqx stops 2019-05-28 17:11:31 +08:00
Gilbert 0857b976ed Better zone (#2548) 2019-05-25 22:29:23 +08:00
HeeeJianBo 87ffa77ade Fix lookup_session_pids return data type error 2019-05-25 22:28:34 +08:00
turtled 54f2a768a8 Rm start logger:set_primary_config 2019-05-23 10:51:21 +08:00
Gilbert Wong 1c83270184 Add case clause for emqx_sn and emqx_coap plugin 2019-05-21 11:19:52 +08:00
HeeeJianBo caa582a028 Revert the PR #2355
- Add anonymous field for credentials
2019-05-15 15:04:27 +08:00
JianBo He 1a92f3259f Enable cert_as_username to pass value to username_as_clientid (#2536) 2019-05-15 10:20:04 +08:00
JianBo He 79c1b7eb78
Put sockname to credentials (#2532)
* Add sockname to credentials

* Explicit credentials type define
2019-05-14 10:22:30 +08:00
JianBo He 97cca1a5ba Set {active, N} for ssl connection (#2531) 2019-05-13 10:18:01 +08:00
turtleDeng 311f1e6df1
Merge pull request #2521 from emqx/develop-3.2 2019-05-09 11:16:14 +08:00
Gilbert Wong fc6f54602d Fix plugin load bug 2019-05-08 14:23:12 +08:00
tigercl 7e0ac5bd34
Fix bad config type of long_gc (#2504) 2019-05-08 10:19:49 +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
tigercl b4c659fb54 Add suboptions for stats (#2507) 2019-05-06 19:17:54 +08:00
Gilbert Wong 3ece73b912 Reuse plugin filter logic to adapt to emqx rebar3 release 2019-05-06 13:34:55 +08:00
turtled ea83d2087c Optimize log configuration 2019-05-05 14:35:43 +08:00
turtled c5524e99c6 Rm emqx_rate_limiter module 2019-04-25 14:29:20 +08:00
Gilbert eaa1deab20 Refactor flapping code (#2476)
* Refactor flapping code
2019-04-24 10:42:26 +08:00
Gilbert Wong bcbb4b68e9 Add flapping detect feature 2019-04-19 16:34:33 +08:00
Gilbert Wong 5680b191ee Extend status api 2019-04-18 14:12:06 +08:00
Gilbert 94aa173858 Fix bugs of keepalive value init of emqx_client (#2443)
Fix bugs of keepalive value init of emqx_client
2019-04-17 10:43:20 +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 4d2bc48822 Redesign ensure_start and ensure_stop api of bridge 2019-04-11 18:17:30 +08:00
Gilbert 4fc81cef85
Change log level unexpected info in client (#2422)
Change log level for unexpected info in client and rejust code format in emqx_bridge
2019-04-11 12:20:32 +08:00
周子博 6a4c318acb Update metrics when session process terminates 2019-04-11 10:08:26 +08:00
Shawn a53320069b Fix trace logger level not work (#2408)
* Fix trace logger level not work #2385
2019-04-10 09:14:53 +08:00
Gilbert Wong eb7b1797c2 Provide bridge handler to extense emqx_bridge 2019-04-09 19:03:07 +08:00
Gilbert Wong 627ea0afe8 Add `is_bridge_exist` api in emqx_bridge_sup 2019-04-09 11:40:36 +08:00
Gilbert Wong 8cfd080a97 Fix gen_statem:reply/2 bug in emqx_client module
Prior to this change, the arguments passed to gen_statem:reply is bad
args, first arg should be a tuple, but it is a pid. So it would
trigger crash.

This change fix this bug.
2019-04-08 11:50:28 +08:00
Gilbert Wong 7e6255d4ee Set default websocket idle timeout to 2 hour 2019-04-04 17:42:52 +08:00
Gilbert e917c025d0
Fix LOG on line 231 2019-04-04 17:38:36 +08:00
JianBo He aad2d7378e Put peername into messsage headers (#2390)
* Put peername into the message.heaers
2019-04-04 13:41:03 +08:00
Gilbert Wong 287c5582a9 Fix compilation warning 2019-04-03 20:49:45 +08:00
Gilbert Wong 15f8d3208f Fix message dropped
Prior to this change, when store_qos0 option is set to false, the hook
`message.dropped` would not be triggered. It is wrong design and when
the ignore_loop is enabled or nl is set to 1, the hook
`message.dropped` also would not be triggered.
2019-04-03 20:33:58 +08:00
Shawn 2306789755 Remove bin_key_map/1 (#2393)
* Remove bin_key_map/1

* Fix Travis-CI failure
2019-04-03 19:41:21 +08:00
spring2maz 55d2d1d278 Allow boolean flag for loaded plugins
This is to simplify config templating
2019-04-03 19:35:24 +08:00
Feng Lee 60c2b8bc08 Add more functions to read fields of 'message' record
- Add id/1, topic/1, from/1, payload/1 and timestamp/1 functions
- Improve the test cases
2019-04-02 15:15:13 +08:00
HeeeJianBo 2d2520627a Fix topic 'datatype' to 'datetime' 2019-04-01 11:37:22 +08:00
Gilbert Wong 0c64da6da7 Change default log level from info to critical when shutdown 2019-03-29 10:57:52 +08:00
Gilbert b6fa4d2a3f
Fix bridge subscribe bugs 2019-03-29 10:19:11 +08:00
周子博 f14a56eb17 Fix acl bug in subscribe 2019-03-28 14:04:04 +08:00
Gilbert Wong 114b28f973 Delete function clause which would reply {error,standing_by} 2019-03-28 11:47:29 +08:00
Gilbert 0d6b937127 Support proxy protocol of websocket (#2372)
Support proxy protocol of websocket
2019-03-28 10:34:48 +08:00
HeeeJianBo 24f8c3a391 Fix drain the session process mailbox handling err 2019-03-28 10:32:03 +08:00
周子博 6e3c4b0855 Fix conflict 2019-03-27 13:59:26 +08:00
Shawn a3fd8846a5
Bin key map (#2362)
Suppport nested bin-key map
2019-03-27 11:12:28 +08:00
turtleDeng e6d90d5758
Improve mountpoint (#2363) 2019-03-27 11:10:51 +08:00
周子博 0fbf771543 Readjust log level into error when got unexpected message 2019-03-27 11:07:58 +08:00
JianBo He c223f62c5a Put cn/dn of client cert into credentials (#2357)
Put cn/dn of client cert into credentials
2019-03-27 10:20:12 +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
tigercl f5c426a2f2
Add missed case for monitors (#2353) 2019-03-27 10:18:51 +08:00
周子博 58e1b4d485 Readjust log level and unify log format 2019-03-26 22:18:31 +08:00
Shawn f0fa9a9252 Add a function converting message to binary-key map (#2360) 2019-03-26 10:35:10 +08:00
JianBo He 8d92d58b6c Fix allow_anonymous behavoir error (#2355)
EMQ should allow the anonymous connection if the allow_anonymous option is true, although it has one or more auth plugins started.
2019-03-26 10:25:51 +08:00
Shawn 9e7b3a9209
Update emqx_types.erl 2019-03-22 16:27:23 +08:00
terry-xiaoyu bd304572c9 Delete acl_mod and auth_mod 2019-03-22 16:18:42 +08:00
terry-xiaoyu c7a317afaf Add one more connack reason code 2019-03-22 15:43:21 +08:00
HeeeJianBo fc2df9aff5 Adapt to new export style 2019-03-22 14:58:24 +08:00
Gilbert e386778aca Fix typo 2019-03-22 11:31:26 +08:00
Feng Lee dba16aeea5 Add 'remove_header/2', 'get_headers/1' functions
- Adopt new 'export' style
- Add 'remove_header/2', 'get_headers/1' functions
- Remove 'remove_topic_alias/1' function
2019-03-22 11:31:26 +08:00
Feng Lee ba719a896d Call 'tokens/1' instead of 'words/1' 2019-03-22 11:31:26 +08:00
Feng Lee a4550a8fc4 Add emqx_topic:tokens/1 function 2019-03-22 11:31:26 +08:00
JianBo He 513d2bcaaa Fix reload ACL failed (#2344)
The original `reload_acl` function only parse the ACL file, not compile and rehook to 'client.check_acl'
2019-03-22 10:21:16 +08:00
turtled 416bc75d5d Sort plugin list 2019-03-22 01:02:30 +08:00
turtled 865ef864db Get the plugins list through -emqx_plugin module attributes 2019-03-22 00:03:53 +08:00
terry-xiaoyu b79bf13ae7 Rename result -> auth_result 2019-03-22 00:03:34 +08:00
HeeeJianBo 998684fc4e Fix badmatch error in the batch_process of session 2019-03-21 17:40:02 +08:00
terry-xiaoyu 36927f01e7 Add type definition for auth_result 2019-03-21 16:54:50 +08:00
tigercl e7320620c0 Fix alarm report bug (#2332) 2019-03-21 16:53:46 +08:00
linjun 3a2f6d5a6c Fix badmatch bug for reload_acl 2019-03-21 16:51:57 +08:00
tigercl 5a401c44fd Clear dup flag if message published first (#2337) 2019-03-21 10:13:41 +08:00
JianBo He 8a73c62f66 Fix followed packet parse failure (#2333)
To fix issue#2303(https://github.com/emqx/emqx/issues/2303)
It will report the following error, when a connection sends a TCP frame contained many of MQTT packet and followed a split MQTT packet.
2019-03-20 10:14:52 +08:00
turtleDeng a95ebcd7d6
Fix typo 2019-03-17 00:23:44 +08:00
YoukiLin 88c32b2c41 Fix emqx_rpc badargs bug 2019-03-16 21:27:41 +08:00
Gilbert Wong 763115e149 Delegate serialize fun into sendfun 2019-03-16 21:15:10 +08:00
spring2maz a72a914fb8 Fix issue #2312 (#2313)
* Fix SSL option parser

* Fix bridge disconnect log formatting

* Set no headers if new headers is undefined
2019-03-16 19:28:57 +08:00
YoukiLin 29f4faa7dd Add badtcp clause to handle gen_rpc (#2314) 2019-03-16 18:23:18 +08:00
terry-xiaoyu 901bbdedd6 Add some auth error codes 2019-03-16 16:30:25 +08:00
terry-xiaoyu 749494c277 Change default internal-rules to #{} 2019-03-16 13:08:11 +08:00
terry-xiaoyu 2912d9a41b Rename is_super -> is_superuser 2019-03-16 12:51:45 +08:00
terry-xiaoyu a7adb79f17 Allow empty zone in credentials 2019-03-16 12:25:39 +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
spring2maz f2df92fef2 Unload emqx_alarm_handler before unloading plugins when shuting down (#2316)
emqx_alarm_handler publishes mqtt messages,
having it running while plugins are shutdown triggered some
annoying crashes
2019-03-15 17:11:24 +08:00
Feng Lee 56718e35cb Add emqx_topic:tokens/1 function (#2305)
* Add emqx_topic:tokens/1 function
2019-03-13 23:31:44 +08:00
Shawn 111b66121c
Support TLS/DTLS PSK (#2297)
* Improve filter functions for emqx-hook

* Add PSK hook

* Reset hook args for filter functions
2019-03-13 22:24:19 +08:00
spring2maz 48450d1d37 Move request response out of emqx client (#2293)
* Delete response_topic_prefix

The Response-Infomation in CONNACK was misinterpreated, it should
not be a broker's global config, instead, it should be per-client
or even per-session prefix/suffix mechanism

* Delete request-response code from emqx_client

* Add request-response test code

* meck as default dependency --- temp workaround for dep-vsn-check
2019-03-13 11:27:25 +08:00
turtled b51747f03e Export find_plugin 2019-03-12 22:45:50 +08:00
linjun f166b81702 Use broker_sys_interval instead of sys_interval 2019-03-12 10:15:13 +08:00
spring2maz 252b376e48 Use keep_state_and_data in emqx_client to avoid unnecessary var binding 2019-03-05 04:04:20 +01:00
spring2maz 656429fcc1 Move emqx_client should_ping function to internal block 2019-03-05 03:57:20 +01:00
spring2maz a056a4cbde Eliminate {error, inflight_full} from publish call to emqx_client
Prior to this change, if a emqx_client:publish/? caller sends in
QoS=1/2 messages too fast, emqx_client may return
`{error, inflight_full}` which could put put the caller to an
awkward situation: there seem to be no ohter option except for
putting self to a sleep-n-retry infinite loop.

In this change, a new gen_statm state 'inflight_full' is introduced
as a sub-state of 'connected'. When emqx_client is in 'inflight_full'
state, it postpone all publish calls (for QoS=1/2) until inflight
window size shrinks.
2019-03-05 03:47:33 +01:00
turtled 22aa7d4668 Rm acl_deny_action_ct test case 2019-02-28 22:19:19 +08:00
tigercl da755b88c7 Add monitors and alarm handler (#2266)
* Add monitors and alarm handler
2019-02-28 18:25:17 +08:00
turtled f1d751dd95 Fix compile fail 2019-02-28 17:06:40 +08:00
Gilbert b1ca0120a2 Move bridge modules out of bridge directory (#2273) 2019-02-28 17:04:39 +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
turtled 8792f7e02b Review code 2019-02-28 16:56:04 +08:00
linjun 814fd3fc9e Fix test case 2019-02-28 16:36:47 +08:00
Gilbert Wong 055d0ad98e Fix typo 2019-02-28 15:39:11 +08:00
Gilbert Wong 7efd7b3ec0 Rename portal to bridge 2019-02-28 15:31:54 +08:00
Gilbert 771f8c052a
Merge branch 'develop' into introduce-new-bridge-impl 2019-02-28 15:14:40 +08:00
Feng Lee 3e0fa87209 Remove the io:format 2019-02-28 15:09:13 +08:00
Feng Lee e3bc8e4f0a Support batch delivery
- Upgrade the emqx_session module to support batch delivery
- Update emqx_protocol:deliver/2 to support batch delivery
- Update some test cases
2019-02-28 15:09:13 +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
Gilbert Wong d18f4ba550 Fix wrong config entries 2019-02-28 11:18:12 +08:00
Gilbert Wong 911a813891 Fix copyright and unify log method 2019-02-28 11:18:12 +08:00
spring2maz 9dbc34c376 Ack replayq and allow retry in tests 2019-02-28 11:17:27 +08:00
Gilbert Wong 75163e21f3 Reverse intensity/period in bridge SupFlag 2019-02-28 11:17:27 +08:00
Gilbert Wong ae92acf30f Refactor portal supervisor 2019-02-28 11:17:27 +08:00
Gilbert Wong ec37225333 Add emqx_portal interfaces 2019-02-28 11:17:27 +08:00
Gilbert Wong 921a45a505 Fix emqx_portal_mqtt_tests start function 2019-02-28 11:17:27 +08:00
spring2maz d4495fd8e7 Add manual start API 2019-02-28 11:17:27 +08:00
spring2maz 1626cade28 Deleted batch publish support in emqx_portal_client
eqmx_portal_mqtt has to do single message publish calls for now
Also fix a bug in emqx_portal_mqtt ack collector
2019-02-28 11:17:27 +08:00
spring2maz 086a1d56b9 Drop unused config schema
bridge.$name.transport was added before we decided to derive
transport portocol based on the 'address' config.
i.e. when it's a remote erlang node, use gen_rpc
otherwise (must be IP or hostnmae), we should estabilish mqtt connection
2019-02-28 11:17:27 +08:00
spring2maz efc9e34033 Make use of BUMP_PACKET_ID the only way to generate packet IDs 2019-02-28 11:17:27 +08:00
Gilbert Wong d7e18c95c6 Fix spelling error 2019-02-28 11:17:27 +08:00
spring2maz 786a6eb696 Add APIs for subscription add / delete 2019-02-28 11:17:27 +08:00
spring2maz 599f5c8d4f Add API emqx_portal:ensure_forward_absent 2019-02-28 11:17:27 +08:00
spring2maz 2903a810ce Add emqx_portal:ensure_foreard_present API 2019-02-28 11:17:27 +08:00
spring2maz 9e78c18681 Add get_forwards and get_subscriptions protal APIs 2019-02-28 11:17:27 +08:00
spring2maz 67376727c9 Add batch send support for emqx_client:publish/2
also cover emqx_portal_mqtt with CT
2019-02-28 11:17:27 +08:00
spring2maz b9e8bde3b0 Add first CT test for emqx_portal based on rpc 2019-02-28 11:17:27 +08:00
spring2maz 6d51d78dfc Add portal transport over emqx_client. 2019-02-28 11:17:27 +08:00
spring2maz 141af0d02c Add message handler callbacks option to emqx_client
In this commit, msg_handler option is added to emqx_client.
so the caller can provide callbacks to handle puback, publish,
as well as disconnected events instead of always delivered
as message like Owner ! {publish, Msg} to the owner process.

This is to make it ready to implement emqx_portal_connect on
top of emqx_client.
2019-02-28 11:17:27 +08:00
spring2maz fbe67e6784 Introduce new bridge impl 2019-02-28 11:17:27 +08:00
Gilbert c3e6f3c3b2 Improve try catch syntax (#2263)
* Replace case catch.. with try ... catch
Prior to this change, case catch ... would cost a lot of performance
because it would retrieve the whole stacktrace. However, try...catch
will not retrieve the whole stacktrace. So try...catch syntax is better.
2019-02-28 09:54:28 +08:00
linjun 44529a278d Adjusting code 2019-02-27 14:39:49 +08:00
linjun e1a5188d09 Adjusting code 2019-02-27 14:00:11 +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
Feng Lee c8b243ed22 Change some '-type' attrs to '-opaque' and improve emqx_gc, emqx_inflight modules
- Define 'GCS(St)' macro to improve emqx_gc module
- Define 'Inflight(MaxSize, Tree)' macro to improve emqx_inflight module
2019-02-22 18:08:13 +08:00
Feng Lee 565c1a8c85 Optimize unset_flag/2 and add some specs
- Optimize unset_flag/2
- Add some function specs
- Add emqx_message_SUITE to Makefile
2019-02-22 17:06:52 +08:00
Feng Lee 82c337a040 Fix 'drpped' typo
- Fix 'drpped' typo
- Add specs for exported functions
- Add 'group()' type in emqx_topic module
2019-02-22 10:03:29 +08:00
Feng Lee 7a645dd9cc Add 'include/types.hrl' and introduce some common types 2019-02-19 17:16:11 +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
turtleDeng 00863acea3
Merge emqx30 (#2181)
* Change the reason code in will topic acl check (#2168)

* Fix bridge bug (#2160)

* Limit bridge QoS less than 1

* Improve shared sub dispatch implementation. (#2144)

* Upgrade ekka, esockd libraries

* Improve the 'try_open_session' function

* Reload config (#2180)
2019-01-25 13:01:48 +08:00
Shawn b8929a46c1 Fix the EXIT outputs in Travis CI (#2154)
* Fix the Exit in testcases

* Fix Exit in emqx_mod_sup_SUITE

* Update testcases for log_tracer

* Fix Exit in emqx_protocol_SUITE

* Add will_acl_check

* Fix more Exits
2019-01-17 17:14:51 +08:00
tigercl bc31faac6b Fix will msg (#2156)
* Remove will_msg and will_topic from protocol state

* Modify try_open_session/1
2019-01-17 13:57:42 +08:00
Gilbert Wong ec03f8e1fa Fix the deliver packet bug and add test case 2019-01-11 16:41:20 +08:00
turtleDeng a5f9466040 QoS0 msg support msgid (#2145)
* QoS0 msg support msgid

* Fix testcase
2019-01-11 11:47:10 +08:00
Feng Lee 5ccaaed34c Add 'next_events/1' and fix the 'process_incoming/3' function 2019-01-10 09:23:05 +08:00
Feng Lee 3e15ac0bbb Improve the design of 'emqx_client' module
Use '{next_event, cast, Packet}' to replace 'gen_statem:cast/2'
2019-01-10 09:23:05 +08:00
Feng Lee 30f32de13a Use map to replace 'state' record 2019-01-10 08:53:10 +08:00
Feng Lee e882af9369 Use the new logger macros 2019-01-10 08:53:10 +08:00
Feng Lee fe0f5333b3 Improve the pool design
- Move 'emqx_pool:start_link/0' to emqx_pool_sup module
- Use the new log macros
- Add more test cases
2019-01-10 08:49:58 +08:00
Feng Lee 4230a3c535 Optimize the trie match 2019-01-09 11:57:22 +08:00
Feng Lee 0c418581b2 Add emqx_trie:empty/0 and optimize match_routes/1 2019-01-09 11:57:22 +08:00
Gilbert dee88fb018 Fix mem cache bug (#2129) 2019-01-07 14:15:27 +08:00
Shawn 0d9929fdaa Logger level in one command (#2115)
* Refactor logger-level-in-one-command

* Update API
2019-01-07 11:40:54 +08:00
Shawn cb93a356a0 Fix crash if peer closed the connection (#2120)
Prior to this fix, we'll get the following crash if we connected to
another emqx broker but got refused because of wrong username or password.
2019-01-07 11:40:05 +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
Shawn 69954480bf
Hook args (#2119) 2019-01-03 13:54:31 +08:00
YoukiLin 78b3c375d8
Improving 'emqx_ws_connection' coverage (#2107) 2019-01-03 12:59:39 +08:00
Gilbert 9a2573d54b Refactor bridge (#2117)
* Refactor bridge
2019-01-03 09:10:43 +08:00
Gilbert 72791b569e
Improve app src (#2114)
* Add replayq in emqx.app.src

* Fix publish_readq_msg badmatch
2018-12-28 20:04:52 +08:00
Gilbert Wong eed03ee297 Add replayq in emqx.app.src 2018-12-28 19:53:58 +08:00
turtleDeng 6a1ebe299a
Merge emqx32 to emqx30 (#2112) 2018-12-28 19:44:41 +08:00
Shawn d854120023
Show plugin name if cannot start it (#2111) 2018-12-28 16:37:01 +08:00
Gilbert 1797aadbe7 Fix unsuback compat (#2102) 2018-12-22 18:47:38 +08:00
tigercl edf0ded9f3 Fix bug that no update message expiry interval (#2101) 2018-12-22 11:32:22 +08:00
turtled f7596b8131 Fix session shutdown bug 2018-12-21 22:44:58 +08:00
Feng Lee bb45825e77 Inc deliver_stats, enqueue_stats with emqx_pd:update_counter/2 (#2100) 2018-12-21 18:31:04 +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
turtled 7d3357e0f3 Merge emqx32 2018-12-21 16:01:32 +08:00
YoukiLin e949e8cbd8 Add format output for test print (#2076)
* Add formatted output for the test print
2018-12-21 15:42:42 +08:00
Feng Lee 10e5210581 Workaround ssl:setopts(SslSock, [{active, N}]) (#2095)
* Set '{active, true}' for SSL socket
2018-12-21 15:39:24 +08:00
tigercl 31bf01fd7a Fix bug in topic alias maximum (#2074)
* Fix bug in topic alias maximum
2018-12-21 14:01:21 +08:00
Feng Lee 3fec9cdf0a Try to simulate a '{ssl_passive, Sock}' message:( 2018-12-21 12:03:40 +08:00
turtleDeng 4f84a31d02
Update copyright (#2093) 2018-12-21 11:06:50 +08:00
Gilbert bf7f10ecd1 Add will topic validation and acl check (#2075)
* Add will topic validation and acl check
2018-12-21 10:49:03 +08:00
Feng Lee 367b717c40 Implement a new 'emqx_gc' module (#2090)
Update connection/session module to using the new emqx_gc API
2018-12-20 22:42:18 +08:00
turtled b4833d6973 Fixed conflicts 2018-12-20 22:23:20 +08:00
tigercl 938d30268a Remove extra case...of (#2082)
* Remove extra case...of
2018-12-20 21:42:14 +08:00
YoukiLin 6b538d2363 Add test cases for 'emqx_cm' and 'emqx_sm' (#2073)
Add test cases for 'emqx_cm' and 'emqx_cn'
2018-12-20 21:03:40 +08:00
Feng Lee 14cffcf7fb Add the 'emqx_pd' module
Add utility functions for erlang process dictionary
Add test cases for emqx_pd
2018-12-20 16:45:25 +08:00
Feng Lee 14a12e0c6c Move the 'LOG_HEADER' macro above '-include(logger.hrl)' 2018-12-20 14:45:52 +08:00
Feng Lee 6e1b47f1f9 Improve the emqx_connection module
Rename 'publish_limit' to 'pub_limit'
'try ... of ... catch' to replace 'case catch'
2018-12-20 14:45:52 +08:00
Feng Lee d827604213 Remove the ensure_stats_timer/1 call from reply/2 and noreply/1 2018-12-20 11:33:18 +08:00
Feng Lee 42fc8f5811 Improve the session module 2018-12-20 10:21:40 +08:00
tigercl 97474171d0 Better report errors in acl.conf (#2065) 2018-12-19 23:06:48 +08:00
turtled 7a1ec580b0 Update broker test cases 2018-12-19 17:18:26 +08:00
Feng Lee 892d9439b9 Implement a new session supervisor. (#2077) 2018-12-19 16:49:35 +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
turtled 666d9706a3 Fixed conflicts 2018-12-18 16:41:10 +08:00
turtled 1e2c5db36c Modify batch size 2018-12-18 15:42:54 +08:00
Feng Lee dc06c0beab Remove 'topic_alias_maximum' from session's state 2018-12-18 15:11:04 +08:00
tigercl 95ad67b47c Fix a bug that will not send a will message in some cases (#2068)
* Fix a bug that will not send a will message in some cases
2018-12-18 14:55:37 +08:00
周子博 b7a39f25f2 Revert "Fix a bug that will not send a will message in some cases"
This reverts commit 675edf3fab.
2018-12-18 12:02:18 +08:00
周子博 675edf3fab Fix a bug that will not send a will message in some cases 2018-12-18 12:01:41 +08:00
Feng Lee 721b72b96a Add 'active_n' option to optimize the CPU usage of emqx_connection (#2060)
* Add 'active_n' option to optimize the CPU usage of emqx_connection

* Supports batch processing 'DOWN' events
2018-12-17 19:53:29 +08:00
turtled f54d414825 Fix pick fail 2018-12-15 13:42:07 +08:00
turtled 34370ef622 Merge branch 'issue#1983' into emqx30 2018-12-14 17:55:36 +08:00
Feng Lee abe9aff062 Add 'enable_session_registry' config 2018-12-13 18:28:32 +08:00
Feng Lee 7fe3d59c28 Update the registered name of pool sup. 2018-12-13 17:54:22 +08:00
Feng Lee 4aaf0a7db4 Remove emqx_session_sup to handle massive concurrent sessions 2018-12-13 17:10:02 +08:00
Feng Lee 4e1d1bd60f Remove the emqx_session_sup module 2018-12-13 17:10:02 +08:00
Feng Lee a68e3f265d Fix 'badarg' crash 2018-12-12 16:34:55 +08:00
Feng Lee d8cbf72da1 Fix 'badarg' crash 2018-12-12 16:32:58 +08:00
Feng Lee 8f2f4b6b81 Optimize connection and session management 2018-12-12 16:21:30 +08:00
Feng Lee 8d50c62a94 Optimize connection and session management 2018-12-12 16:10:16 +08:00
Feng Lee 99872b253f Fix 'function not exported' crash 2018-12-12 14:53:22 +08:00
Feng Lee 2a747c9d53 Improve the subscription sharding. 2018-12-12 13:40:01 +08:00
Feng Lee 33830d8120 Improve the design of trie, router and broker modules
1. Add do_add_route/1 do_add_route/2, do_delete_route/1,
do_delete_route/2 APIs in emqx_router module
2. Improve the code of emqx_trie module
3. Update the emqx_broker module to call the new APIs of emqx_router
2018-12-12 13:40:01 +08:00
Feng Lee 47e3cd3692 Improve the subscription sharding. 2018-12-12 13:34:13 +08:00
Feng Lee cca5081e02 Improve the design of trie, router and broker modules
1. Add do_add_route/1 do_add_route/2, do_delete_route/1,
do_delete_route/2 APIs in emqx_router module
2. Improve the code of emqx_trie module
3. Update the emqx_broker module to call the new APIs of emqx_router
2018-12-10 18:37:42 +08:00
周子博 ec2e289776 Fix crash in emqx_acl_internal:filter/2 2018-12-10 11:13:25 +08:00
Feng Lee fb7b63c59b
Merge branch 'emqx32' into subscription-sharding 2018-12-10 10:08:18 +08:00
Gilbert Wong e0eb76afa6 Fix subscription 2018-12-08 16:09:54 +08:00
Feng Lee 64f62fa0ce Make some processes hibernate after 1s. 2018-12-08 15:03:34 +08:00
Feng Lee f008ceb5c8 Optimize the route and trie modules.
1. Use mnesia:wread/1 to replace mnesia:read/2
2. Update the router supervisor
2018-12-08 15:03:34 +08:00
Gilbert 0b70896456 Fix the coverage shaky (#2010) 2018-12-08 15:03:34 +08:00
spring2maz b6c123b173 Use git tag for app vsn 2018-12-08 15:03:34 +08:00
turtled 5164d0d6a5 Fix unsubscribe fail and rename shared -> shard 2018-12-08 11:40:08 +08:00
turtled d1be51d398 Format code 2018-12-08 10:52:15 +08:00
turtled ba897e51f9 Subscriber down clear emqx_suboption table 2018-12-08 10:26:50 +08:00
turtled 5e53eaeee5 rename shard shared 2018-12-08 09:56:00 +08:00
Feng Lee 36e7d63d66 Implement subscription sharding.
1. Improve the design router, broker and shared_sub
2. New ets tables' design for subscription sharding
2018-12-07 18:20:09 +08:00
Feng Lee bce1ddc5c4 Implement a hash-based subscription sharding 2018-12-06 18:45:07 +08:00
Feng Lee d11e734dae Make some processes hibernate after 1s. 2018-12-05 10:31:11 +08:00
周子博 35e699e54e Make sure test case of emqx_banned passes 2018-12-04 16:11:25 +08:00
Feng Lee b4d981daf2 Add a sequence module to generate index for subscription sharding 2018-12-04 15:59:24 +08:00
周子博 b2c3d8366d Add logs for malformed acl configuration file 2018-12-03 13:57:37 +08:00
Feng Lee 95446ca837 Optimize the route and trie modules.
1. Use mnesia:wread/1 to replace mnesia:read/2
2. Update the router supervisor
2018-12-03 11:10:47 +08:00
Gilbert 295a9d692e
Fix the coverage shaky (#2010) 2018-11-30 19:16:48 +08:00
spring2maz 14dfe03426 Use git tag for app vsn 2018-11-30 11:03:26 +01:00
Feng Lee d9470f365f Optimize read/write concurrency of mnesia/ets tables 2018-11-30 17:46:15 +08:00
Feng Lee e15e5d1f98 Fix the atom leaks in emqx_reason_codes module. 2018-11-30 17:45:28 +08:00
周子博 fde5fbe73a Align the code 2018-11-30 17:44:29 +08:00
周子博 ad8b547519 Make batch committing of metrics more elegant 2018-11-30 17:44:29 +08:00
周子博 f315994eb9 Remove unnecessary spec 2018-11-30 17:44:29 +08:00
周子博 c87aabbbeb Some forgotten changes in last commit 2018-11-30 17:44:29 +08:00
周子博 ea62b15c87 Alter apis provided by emqx_metrics, and use existing timer to commit metrics 2018-11-30 17:44:29 +08:00
周子博 194dbc02c8 Add batch commit for metrics 2018-11-30 17:44:29 +08:00
Feng Lee 21ed012a0c Add an elegant batch module 2018-11-29 10:13:09 +08:00
Feng Lee 309f3560f3 Bump version to 3.0.0 2018-11-28 16:05:17 +08:00
周子博 5c291ff23e Fix the 'route_batch_delete' config 2018-11-28 16:04:04 +08:00
周子博 78fdb798f8 Update vsn 2018-11-26 13:51:32 +08:00
Shawn eeb0cab3e3 Update proc meta-data for empty clientid (#1980) 2018-11-23 18:11:46 +08:00
Shawn 6fa183f847 Add CLI for log level (#1977) 2018-11-23 11:04:33 +08:00
Shawn 2bd0f16884 Add CLI for log tracer (#1973) 2018-11-23 11:01:10 +08:00
tigercl 551d5d99d2 Change 'aquire' to 'acquire' (#1976)
* Change 'aquire' to 'acquire'
2018-11-23 11:00:30 +08:00
tigercl 14b8036576 Use username replace id(issue#1737) (#1961)
* Use username replace id(issue#1737)

* Add test case for issue#1737

* Make with_connection/2 support batch connect
2018-11-21 22:51:33 +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
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
Andrei Nesterov 9d67a64165 Fix type validation for User-Property 2018-11-19 09:53:43 +08:00
terry-xiaoyu 078584172e Print EMQ X Version in the console 2018-11-10 12:14:26 +08:00
turtled faeda253e1 Fix conflicts 2018-11-10 11:44:55 +08:00
terry-xiaoyu 6e26f5e9af Revert logger print to io:format 2 2018-11-10 11:25:52 +08:00
terry-xiaoyu 2611b6fc2a Revert logger print to io:format 2018-11-10 11:01:11 +08:00
周子博 c76e2d1413 Fix 'badarg' in io_lib:format/2 when 'from' field is tuple 2018-11-09 18:32:26 +08:00
terry-xiaoyu 997958aed1 Change the start_link API for emqx_client
Prior to this change, emqx_client:start_link does 2 works in one call:
- init an erlang process for emqx_client
- send MQTT CONNECT to remote broker

But this solution have some drawbacks:

- the return value of `start_link` compiles the return values of the 2
 works: {ok, Pid, MqttResult}. It is inconsistent with the return value
 of `gen_statem:start_link`, may causes confusions.

- the return mode of the 2 works are different:
  `start_link` should always return {ok, Pid} or {error, Reason}, but
 connecting to mqtt may throw out exceptions as it handles the
 socket. But the caller couldn't have thought of the exception, he would
 pattern match on the result of `emqx_client:start_link`, but it crashed!

- If the init work succeed but the connection failed, the caller couldn't
get a Pid from the return value, but indeed it was created inside the
emqx_client. This hides the fact that the Pid was created, and when the
Pid dies, the caller would receive an message from a Pid it doesn' know about.

This change divived these 2 work into 2 APIs:
- `start_link/1` is to build and verify the options, and returns {ok,Pid}
 (on success) or {error, Reason} (on failure).
- `connect/1` is to send MQTT CONNECT, and returns {ok, MQTTResult::properties()} or
 {error, MQTTReason}. MQTT reason codes will contains in the `MQTTReason`.
2018-11-09 17:43:04 +08:00
terry-xiaoyu 2dc8ec8b11 Bridge via TLS 2018-11-09 17:43:04 +08:00
tigercl 3879dcdf59 Fix 'badarg' bug with duplicate subscriptions (#1943) 2018-11-08 23:02:35 +08:00
Gilbert Wong 32d3826440 Replace macro QOS$i to QOS_$I
The two styles of qos macro name in one project is chaotic. It is not
a good practice.

So I change the QOS$i to QOS_$i
2018-11-08 20:42:31 +08:00
turtleDeng 0a337cbcb4
Merge pull request #1905 from emqx/Fix-for-mqtt-sn
Fix the init_proc_mng_policy bug
2018-11-05 22:30:51 +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 92cc171aaf Support tracing log files for specific topics or clients 2018-11-02 18:38:07 +08:00
terry-xiaoyu 94dbdffd59 New logger formatter with meta-data 2018-11-02 18:38:07 +08:00
spring2maz ae743ad1f0 Rewrite emqx_mqueue.erl
Fixed bugs:

- Priority queue lack of a `len + 1` logic in `in/2`

Changed behaviors:

- Topics not found in priority table (from config) will be treated with default priority,
  instead of hasing topic name to a priority number.
- Default priority is now configurable (it was always lower than all configured priorities)
- The dropped message due to reaching `max_len` is now returned from `in/2`,
  so the queue owner (`in/2` caller) can perform autopsy on it
2018-10-27 14:21:53 +02:00
tigercl 64cb920b3b
Merge branch 'emqx30' into improve_connect 2018-10-27 14:27:25 +08:00
周子博 3cea06f88f Remove resume_session/1, 2018-10-27 14:25:10 +08:00
周子博 7c14ba11d6 Set some attributes when session resumed 2018-10-27 13:59:17 +08:00
turtleDeng 8788cb2158
Merge pull request #1921 from emqx/improve_test_cases
Improve test cases
2018-10-26 19:45:18 +08:00
周子博 881e1a9621 Add case for ets:match_object 2018-10-26 19:43:05 +08:00
周子博 92251d4a8a Make more normalize 2018-10-26 17:45:13 +08:00
Gilbert Wong f7285d5a58 Delete ackprops in pstate
Prior to this change, ackprops is duplicated with ack_props

This change delete ackprops.
2018-10-26 17:30:39 +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
Gilbert 7544a21e25
Add test cases for emqx_bridge, emqx_mod_rewrite (#1914) 2018-10-26 14:04:33 +08:00
周子博 db2e47470a Fix bugs 2018-10-25 16:19:57 +08:00
周子博 6675e3d496 Implement will message delay publish in session, add test case for clean start and will message in connect packet 2018-10-25 14:26:31 +08:00
Gilbert Wong a1092a6784 Add eunit cases and fix typo. 2018-10-24 15:59:22 +08:00
周子博 540484e603 Send and cancel will message by apis rather than hook 2018-10-23 17:27:46 +08:00
Gilbert Wong 3f761cbe6a Support use certifate as username
Prior to this change, you can just use CN or EN field from the client
certificate as username.

This change add a new option to allow user to use Certificate directly as
username.
2018-10-23 14:37:05 +08:00
Gilbert 58f5f3c51b
Merge branch 'emqx30' into Fix-for-mqtt-sn 2018-10-23 13:29:45 +08:00
Gilbert Wong 35460d8227 Refactor send_fun 2018-10-22 09:04:03 +08:00
tigercl 55a12c1ab4
Merge branch 'emqx30' into improve_connect 2018-10-19 16:03:17 +08:00
Gilbert 4c40f75f4b Request & Response (broker and client) (#1819)
Add request & response support for CONNECT & CONNACK

Prior to this change, there is no validate and specified process for
Request-Response-Information and Response-Information

Also added basic Request/Response functionality to emqx_client implementation
2018-10-18 19:21:05 +02:00
Gilbert Wong 30d986c318 Add warning log for unauthored subscribe
Prior to this change, there is no log for unauthored log, it is
difficult to find the problem when subscription error occured.
2018-10-19 01:19:14 +08:00
spring2maz 7e7d99fbad Change more stats callbacks to full M:F/A
Including emqx_sm emqx_cm emqx_router_helper
2018-10-19 00:22:29 +08:00
spring2maz 4082f3ade2 Improve stats test
Before this change, the stats callback provided by emqx_broker_helper
was an anonymous function with module local context.
This commit changes it to a full fun M:F/A style callback for:
1. More robust to hot beam reload
2. Faster/smaller variable to construct
3. Easier test
2018-10-19 00:22:29 +08:00
Gilbert Wong 387f2468c0 Add SendFun case for emqx-sn 2018-10-18 15:01:45 +08:00
Gilbert Wong df713959ab Refactor init_proc_mng_policy.
If there is no zone, it is unnecessary to add proc_mng_policy.
2018-10-18 13:57:27 +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
Gilbert Wong c890792613 Fix the init_proc_mng_policy bug
Prior to this change, when the plugin like emqx_sn_gateway which has
no zone run the init_proc_mng_policy function, it would trigger error
and application crash.

This change add a case to avoid crash.
2018-10-17 17:24:05 +08:00
周子博 29beb42aa2 Using client id rather then session pid 2018-10-10 14:00:17 +08:00
tigercl 40251a034c
Merge branch 'improve_connect' into emqx30 2018-10-09 18:03:22 +08:00
Gilbert Wong d36a34fb59 Fix topic_name validation bug
Prior to this change, Prior to this change, the validation for the mqtt5.0 publish packet
which both contains zero-length topic name and topic alias is wrong.
2018-10-09 17:45:40 +08:00
周子博 b80ba6e458 Fix bug when ConnProps is undefined 2018-10-09 14:19:22 +08:00
周子博 9bcd4c3e08 improve will message 2018-10-09 13:35:27 +08:00
Gilbert Wong 52eae65983 Fix topic_name validation bug
Prior to this change, Prior to this change, the validation for the mqtt5.0 publish packet
which both contains zero-length topic name and topic alias is wrong.

This change fix this bug.
2018-10-08 20:02:32 +08:00
spring2maz e3f2ae8db8 Change from customized total heap size check to set process flag
The `max_heap_size` process flag can be used to limit total
heap size of a process, and it gives much more detailed
crash log if the limit is hit.
2018-09-29 21:36:34 +08:00