Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
I
iot-mqtt-bl
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
deploy
iot-mqtt-bl
Commits
dfb118f5
Commit
dfb118f5
authored
Apr 26, 2023
by
吴文龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
ef630c32
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
haproxy copy.cfg
haproxy/config/haproxy copy.cfg
+28
-0
mqtt_health_check.lua
haproxy/config/mqtt_health_check.lua
+20
-0
No files found.
haproxy/config/haproxy copy.cfg
0 → 100644
View file @
dfb118f5
global
daemon
maxconn 256
defaults
mode tcp
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend mqtt_frontend
bind *:1883
mode tcp
default_backend mqtt_backend
backend mqtt_backend
mode tcp
balance roundrobin
option tcp-check
tcp-check send-binary 303c01000004000000000000
tcp-check expect binary 200201000004000000000000
tcp-check send-binary 100000016d7174742f04020000000c6d7174742d737461747573
tcp-check expect binary 20020001000c6d7174742d737461747573
server mqtt_server1 192.168.1.101:1883 check inter 5s rise 2 fall 3
server mqtt_server2 192.168.1.102:1883 check inter 5s rise 2 fall 3
server mqtt_server3 192.168.1.103:1883 check inter 5s rise 2 fall 3
lua-load /etc/haproxy/mqtt_health_check.lua
haproxy/config/mqtt_health_check.lua
0 → 100644
View file @
dfb118f5
core
.
register_action
(
"mqtt_health_check"
,
{
"tcp-req"
},
function
(
txn
)
txn
:
set_var
(
txn
.
TXN_CHECK_STATUS
,
"L7OK"
)
txn
:
set_var
(
txn
.
TXN_CHECK_CODE
,
"200"
)
txn
:
set_var
(
txn
.
TXN_CHECK_PAYLOAD
,
""
)
if
txn
.
f
:
has_subscribers
()
then
local
ok
,
err
=
txn
.
f
:
publish
(
"mqtt_health_check"
,
"PINGREQ"
)
if
not
ok
then
txn
:
set_var
(
txn
.
TXN_CHECK_STATUS
,
"L7FAIL"
)
txn
:
set_var
(
txn
.
TXN_CHECK_CODE
,
"503"
)
end
end
end
)
core
.
register_subscriber
(
"mqtt_health_check"
,
function
(
applet
)
applet
:
set_status
(
200
)
applet
:
add_header
(
"Content-Type"
,
"text/plain"
)
applet
:
start_response
()
applet
:
send
(
"PONG\n"
)
end
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment