Stomp 协议网关

EMQX 客服发表于:2022年05月16日 16:12:12更新于:2022年07月13日 16:24:47

Stomp 协议网关

Stomp 协议网关为 EMQX 提供了 Stomp 协议的接入能力。

创建模块

打开 EMQX Dashboard,点击左侧的 “模块” 选项卡,选择添加:

image.png


点击 “选择”,然后选择 “Stomp 接入网关”:

image.png


配置相关基础参数:

image.png


添加监听端口:

image.png


配置监听参数:

image.png


点击 “确定” 完成监听器的配置,然后点击 “添加” 完成模块的创建:

image.png


配置参数


配置项说明
最大报文头部数量Stomp frame headers 的最大数量
最大报文头部长度Stomp frame headers 的最大长度
报文体最大长度Stomp frame body 的最大长度
允许匿名登录是否允许匿名登录
默认用户名指定 Stomp 模块登录使用的 Username
默认密码指定 Stomp 模块登录使用的 Password

验证结果:

image.png

STOMP客户端示例:

具体使用教程:https://jasonrbriggs.github.io/stomp.py/quickstart.html

cd teststomp/bin

## 查看stomp可使用选项
./stomp --help
Usage: stomp [options]
Options:  
    --version                    Show the version number and exit  -h, 
    --help                   Show this help message and exit  
    -H <host>, --host=<port>     Hostname or IP address to connect to. [default: localhost]  
    -P <port>, --port=<port>     Port providing stomp protocol connections. [default: 61613]  
    -U <user>, --user=<user>     Username for the connection  
    -W <password>, --password=<password>                               Password for the connection  
    -F <filename>, --file=<filename>           File containing commands to be executed, instead of                                                   
                                               prompting from the command prompt.  
    -S <protocol version>, --protocol=<protocol version>                               
                           Set the STOMP protocol version (1.0, 1.1, 1.2) [default: 1.1]  
    -L <queue>, --listen=<queue> Listen for messages on a queue/destination  
    -V, --verbose                Verbose logging "on" or "off" (if on, full headers                               
                                 from stomp server responses are printed)  
    --heartbeats=<heartbeats>    Heartbeats to request when connecting with protocol >=                               
                                 1.1 (two comma separated integers required) [default: 0,0]  
    --ssl                        Enable SSL connection  
    --ssl-key-file=<key-file>    ssl key file  
    --ssl-cert-file=<cert-file>  ssl cert file  
    --ssl-ca-file=<ca-file>      ssl ca certs file

## 连接EMQX
./stomp -H 192.168.1.19 -P 6161

## 订阅stomp/test主题
> subscribe stomp/test

image.png

image.png

image.png

## 通过stomp协议连接到EMQX的客户端向stomp/demo主题发送一条消息
> send stomp/demo hello EMQX!

通过MQTTX连接一个客户端到EMQX并订阅stomp/demo主题:

image.png

    您需要登录后才可以回复