Skip to content

Commit

Permalink
Merge pull request #111 from thingsboard/mqtt-over-ws-setup
Browse files Browse the repository at this point in the history
[1.2.2] Mqtt over WS setup for WS client
  • Loading branch information
dmytro-landiak authored Mar 20, 2024
2 parents 49812fc + 527a14c commit b6fae72
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ services:
ports:
- "1883"
- "8083"
- "8084"
logging:
driver: "json-file"
options:
Expand All @@ -69,6 +70,7 @@ services:
ports:
- "1883"
- "8083"
- "8084"
logging:
driver: "json-file"
options:
Expand Down Expand Up @@ -97,12 +99,14 @@ services:
- "8083:8083"
- "443:443"
- "1883:1883"
- "8084:8084"
cap_add:
- NET_ADMIN
environment:
HTTP_PORT: 8083
HTTPS_PORT: 443
MQTT_PORT: 1883
MQTT_WS_PORT: 8084
FORCE_HTTPS_REDIRECT: "false"
links:
- tbmq1
Expand Down
10 changes: 10 additions & 0 deletions docker/haproxy/config/haproxy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ listen mqtt-in
server tbMqtt1 tbmq1:1883 check inter 5s resolvers docker_resolver resolve-prefer ipv4
server tbMqtt2 tbmq2:1883 check inter 5s resolvers docker_resolver resolve-prefer ipv4

listen mqtt-ws-in
bind *:${MQTT_WS_PORT}
mode tcp
option clitcpka # For TCP keep-alive
timeout client 3h
timeout server 3h
option tcplog
balance leastconn
server tbMqttWs1 tbmq1:8084 check inter 5s resolvers docker_resolver resolve-prefer ipv4
server tbMqttWs2 tbmq2:8084 check inter 5s resolvers docker_resolver resolve-prefer ipv4

frontend http-in
bind *:${HTTP_PORT} alpn h2,http/1.1
Expand Down
3 changes: 3 additions & 0 deletions k8s/aws/receipts/mqtt-load-balancer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ spec:
- port: 1883
targetPort: 1883
name: mqtt
- port: 8084
targetPort: 8084
name: mqtt-ws
# This way NLB acts as transparent load balancer and forwards all traffic to port 8883 without decryption.
- port: 8883
targetPort: 8883
Expand Down
3 changes: 3 additions & 0 deletions k8s/aws/receipts/mqtts-load-balancer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ spec:
- port: 1883
targetPort: 1883
name: mqtt
- port: 8084
targetPort: 8084
name: mqtt-ws
# This way NLB acts as an TLS termination point and forwards decrypted traffic to 1883 port of the TBMQ.
- port: 8883
targetPort: 1883
Expand Down
2 changes: 2 additions & 0 deletions k8s/aws/tb-broker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@ spec:
name: mqtt
- port: 8883
name: mqtts
- port: 8084
name: mqtt-ws
3 changes: 3 additions & 0 deletions k8s/azure/receipts/mqtt-load-balancer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ spec:
- port: 1883
targetPort: 1883
name: mqtt
- port: 8084
targetPort: 8084
name: mqtt-ws
- port: 8883
targetPort: 8883
name: mqtts
2 changes: 2 additions & 0 deletions k8s/azure/tb-broker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,5 @@ spec:
name: mqtt
- port: 8883
name: mqtts
- port: 8084
name: mqtt-ws
6 changes: 6 additions & 0 deletions k8s/minikube/tb-broker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ spec:
name: mqtt-tcp
- containerPort: 8883
name: mqtt-ssl
- containerPort: 8084
name: mqtt-ws
env:
- name: TB_SERVICE_ID
valueFrom:
Expand Down Expand Up @@ -125,3 +127,7 @@ spec:
targetPort: 8883
nodePort: 30003
name: mqtt-ssl
- port: 8084
targetPort: 8084
nodePort: 30004
name: mqtt-ws
1 change: 1 addition & 0 deletions msa/tbmq/configs/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ services:
ports:
- "8083:8083"
- "1883:1883"
- "8084:8084"
environment:
TB_SERVICE_ID: tbmq
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/thingsboard_mqtt_broker
Expand Down

0 comments on commit b6fae72

Please sign in to comment.