๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • ๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป ๐ŸŒฎ ๐Ÿ’ฌ
๐Ÿ” database

[MQTT] message๋ฅผ ์•ˆ๋ณด๋‚ด๋Š”๋ฐ ๊ณ„์† message๊ฐ€ ์Œ“์ด๋Š” issue

by ๋ฐ”์ฟ„๋ฆฌ 2024. 3. 7.

 

์‚ฌ์‹ค ์ด๊ฑด ๋ฌธ์ œ๊นŒ์ง€๋Š” ์•„๋‹ˆ๊ณ , ์ข€ ๋” ์ž์„ธํ•˜๊ฒŒ ์•Œ๊ณ  ์‹ถ์—ˆ๋‹ค.

์ €๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” mqtt explorer ์— ์—ฐ๊ฒฐ์„ ํ–ˆ๋‹ค.

 

[MQTT] mqtt client์— connect ์•ˆ๋˜๋Š” ๋ฌธ์ œ

ec2 instance๋ฅผ ์ƒ์„ฑํ•˜๊ณ  mosquitto๋ฅผ ์‹คํ–‰์‹œ์ผฐ๋‹ค. ๊ทธ๋ฆฌ๊ณ  mqtt connection tool๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฐ๊ฒฐ์„ ์‹œ๋„ํ•˜๋‹ˆ, ์—ฐ๊ฒฐ์ด ๋ถˆ๊ฐ€๋Šฅํ–ˆ๋‹ค Starting in local only mode. Connections will only possible from clients running on this machine.

bonory.tistory.com

 

์—ฐ๊ฒฐ์„ ํ•˜๊ณ  ๋ณด๋‹ˆ,

๋‚˜ ์—ฐ๊ฒฐ๋งŒ ํ•˜๊ณ  ์•„๋ฌด ๊ฒƒ๋„ ์•ˆํ–ˆ๋Š”๋ฐ ?! ์ž๊พธ ๋ช‡์ดˆ ๊ฐ„๊ฒฉ์œผ๋กœ message๊ฐ€ ์Œ“์ด๋Š” ๊ฒƒ ์ฒ˜๋Ÿผ ์ˆซ์ž๊ฐ€ ๊ณ„์† ๋Š˜์–ด๋‚ฌ๋‹ค.

๋ญ์ง€ ??????? 

 

ํ•œ๋ฒˆ ํ™•์ธํ•ด๋ณด๋‹ˆ

 

mqtt explorer๋กœ ์ฒ˜์Œ ์—ฐ๊ฒฐ์„ ์‹œ๋„ํ•  ๋•Œ ํ•˜๋‹จ์— ์žˆ๋Š”  ADVANCED  ๋ฅผ ํด๋ฆญํ•˜๋ฉด

 

๊ธฐ๋ณธ์ ์œผ๋กœ ์„ค์ •๋œ 2๊ฐœ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

(1) # : subscribe to all topics. (๋ชจ๋“  topic์„ ๋ชจ๋‘ ๊ตฌ๋…ํ•œ๋‹ค.)

(2) $SYS/#

 

(2)์— ๊ด€ํ•ด์„œ๋Š”

 

MQTT Status

MQTT Status. GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

์–˜๋ฅผ ์ฝ์–ด๋ณด๋ฉด ์กฐ๊ธˆ์ด๋‚˜๋งˆ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋‹ค.

 

Clients can find information about the broker by subscribing to topics in the $SYS hierarchy as follows. Topics marked as static are only sent once per client on subscription. All other topics are updated every sys_interval seconds. If sys_interval is 0, then updates are not sent.

 

Note that if you are using a command line client to interact with the $SYS topics and your shell interprets $ as an environment variable, you need to place the topic in single quotes '$SYS/...' or to escape the dollar symbol: $SYS/... otherwise the $SYS will be treated as an environment variable.

 

>> ํ•ด์„

ํด๋ผ์ด์–ธํŠธ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด $SYS ๊ณ„์ธต ๊ตฌ์กฐ์˜ ํ† ํ”ฝ์„ ๊ตฌ๋…ํ•˜์—ฌ ๋ธŒ๋กœ์ปค์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ •์ ์œผ๋กœ ํ‘œ์‹œ๋œ ํ† ํ”ฝ์€ ๊ตฌ๋… ์‹œ ํด๋ผ์ด์–ธํŠธ๋‹น ํ•œ ๋ฒˆ๋งŒ ๋ฐœ์†ก๋ฉ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ํ† ํ”ฝ์€ sys_interval ์ดˆ๋งˆ๋‹ค ์—…๋ฐ์ดํŠธ๋ฉ๋‹ˆ๋‹ค. sys_interval์ด 0์ด๋ฉด ์—…๋ฐ์ดํŠธ๊ฐ€ ์ „์†ก๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

 

๋ช…๋ น์ค„ ํด๋ผ์ด์–ธํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ $SYS ํ† ํ”ฝ๊ณผ ์ƒํ˜ธ ์ž‘์šฉํ•˜๊ณ  ์…ธ์—์„œ $๋ฅผ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋กœ ํ•ด์„ํ•˜๋Š” ๊ฒฝ์šฐ ํ† ํ”ฝ์„ ๋‹จ์ผ ๋”ฐ์˜ดํ‘œ '$SYS/...'๋กœ ๋ฐฐ์น˜ํ•˜๊ฑฐ๋‚˜ $SYS/...'์—์„œ ๋ฒ—์–ด๋‚˜์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด $SYS๊ฐ€ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋กœ ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.

 

>> ์š”์•ฝ

์‹œ์Šคํ…œ ๊ณ„์ธต ๊ตฌ์กฐ๋ฅผ ๊ตฌ๋…ํ•œ๋‹ค! ๋ช‡ ์ดˆ๋งˆ๋‹ค ์—…๋ฐ์ดํŠธ๋˜๋ฉด์„œ ๊ณ„์† ์ •๋ณด๋ฅผ ๋ณด๋‚ด์˜ค๋Š” ๊ฒƒ์ด๋‹ค!

๋ณด๊ธฐ์‹ซ์œผ๋ฉด ์—ฐ๊ฒฐํ•  ๋•Œ $SYS/# ์‚ญ์ œํ•˜๊ณ  ์—ฐ๊ฒฐํ•˜๊ธฐ !! (ํ˜น์€ sys_interval์„ 0์œผ๋กœ ์„ค์ •ํ•ด๋ผ!)

 

$SYS/#์„ ์‚ญ์ œํ•˜๊ณ  ์—ฐ๊ฒฐํ•ด๋ณด์ž

์šฐ์„  ๋‹ค์‹œ ์—ฐ๊ฒฐ ์ง์ „, advanced์˜ Subscription ์—์„œ ๊ธฐ์กด์— ์žˆ๋˜ $SYS/# ์„ ์‚ญ์ œํ–ˆ๋‹ค.

์•„๊นŒ์™€ ๋‹ค๋ฅด๋‹ค.

 

์ž˜ ์ง„ํ–‰๋˜๋Š”์ง€ ์„œ๋ฒ„์—์„œ ํ•œ๋ฒˆ ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด๋‚ด๋ดค๋‹ค.

(test๋ผ๋Š” topic์— 15:54๋ผ๋Š” message๋ฅผ ๋˜์ง)

 

์˜ค ์ž˜ ๋˜๋„น ใ…‹ ๊ตณ ใ…‹

 

+ ์ถ”๊ฐ€๋กœ ์–˜๋„ ์ฝ์–ด๋ณด๋ฉด

 

MQTT Explorer

An all-round MQTT client that provides a structured topic overview

mqtt-explorer.com

 

It basically sends: app version, processor architecture, operating system, used memory, user interactions and error stacks.

 

์ œ์ผ ์•„๋ž˜์— ์ด๋Ÿฐ ๋ฌธ๊ตฌ๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

>> ํ•ด์„ : ๊ธฐ๋ณธ์ ์œผ๋กœ ์•ฑ ๋ฒ„์ „, ํ”„๋กœ์„ธ์„œ ์•„ํ‚คํ…์ฒ˜, ์šด์˜ ์ฒด์ œ, ์‚ฌ์šฉ๋œ ๋ฉ”๋ชจ๋ฆฌ, ์‚ฌ์šฉ์ž ์ƒํ˜ธ ์ž‘์šฉ ๋ฐ ์˜ค๋ฅ˜ ์Šคํƒ์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค.

$SYS/# ์— ํ•ด๋‹นํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค.