MQTT 브로커 mosquitto 도커 컨테이너 띄우기
준비
1. Docker
2. Postman 또는 MQTTX
mosquitto 설치
사용할 이미지
https://hub.docker.com/_/eclipse-mosquitto
eclipse-mosquitto - Official Image | Docker Hub
eclipse-mosquitto •• Eclipse Mosquitto is an open source message broker which implements MQTT version 5, 3.1.1 and 3.1
hub.docker.com
설정 파일 작성
파일명: mosquitto.conf
# This is a Mosquitto configuration file that creates a listener on port 1883
# that allows unauthenticated access.
listener 1883
allow_anonymous true
이 옵션은 모든 접근을 허용하니 프로덕션에서는 사용하지 않는 것을 권장!
컨테이너 실행
sudo docker run --name some-mosquitto -d -p 1883:1883 -v /your/path/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto
테스트
Postman
다운로드 링크: https://www.postman.com/downloads/
Connection 추가
New 버튼 클릭 후 MQTT 추가
연결 정보 입력 및 구독
연결 및 test 발행
파란색 Connect 버튼을 눌러 서버에 연결
Add Topic에 test 입력
Message에 보낼 값 작성 후 Send 클릭
메시지 정상 도착 확인!
MQTTX
다운로드 링크: https://mqttx.app/downloads
Connection 추가
왼쪽 Connections 메뉴창의 + 또는 화면 가운데 New Connection 클릭
연결 정보 입력
오른쪽 Connect를 클릭해 서버와 연결
구독
New Subscription 클릭 후 구독할 토픽 입력
Confirm 클릭
발행
Topic에 test 입력
아래 메시지 창에 전송할 메시지 작성 후 전송 버튼 클릭
메시지 정상 도착 확인!