1、查看restapi端口
# netstat -tnulp|grep 19656
tcp 0 0 0.0.0.0:6369 0.0.0.0:* LISTEN 19656/beam.smp
tcp 0 0 0.0.0.0:18083 0.0.0.0:* LISTEN 19656/beam.smp
tcp 0 0 127.0.0.1:11883 0.0.0.0:* LISTEN 19656/beam.smp
tcp 0 0 0.0.0.0:8883 0.0.0.0:* LISTEN 19656/beam.smp
tcp 0 0 0.0.0.0:9080 0.0.0.0:* LISTEN 19656/beam.smp
tcp 0 0 0.0.0.0:5369 0.0.0.0:* LISTEN 19656/beam.smp
tcp 0 0 0.0.0.0:1883 0.0.0.0:* LISTEN 19656/beam.smp
2、创建访问RestAPI的认证应用ID
[1/3] # ./emqx_ctl mgmt insert <AppId> <Name>
# ./emqx_ctl mgmt insert b28477fa9f9798 Client@Yours
AppSecret: Mjg3ODQxNjgyNTc2Mjg1NDUzNzA3ODczNDM3MDc1Mzc0MDI
[2/3] # ./emqx_ctl mgmt list
app_id: b28477fa9f9798, secret: Mjg3ODQxNjgyNTc2Mjg1NDUzNzA3ODczNDM3MDc1Mzc0MDI, name: Client@Yours, desc: Application user, status: true, expired: undefined
[3/3] curl -v --basic -u <appid>:<appsecret> -k http://<eqmx_node_host>:8080/api/v3/brokers
=> <appid>:<appsecret>,可以通过CLI或者Dashboard进行创建
3、通过认证应用ID和秘钥进行访问
# curl -v --basic -u b28477fa9f9798:Mjg3ODQxNjgyNTc2Mjg1NDUzNzA3ODczNDM3MDc1Mzc0MDI -k http://192.168.1.148:9080/api/v3/brokers/
* About to connect() to 192.168.1.148 port 9080 (#0)
* Trying 192.168.1.148... connected
* Connected to 192.168.1.148 (192.168.1.148) port 9080 (#0)
* Server auth using Basic with user 'b28477fa9f9798'
> GET /api/v3/brokers/ HTTP/1.1
> Authorization: Basic YjI4NDc3ZmE5Zjk3OTg6TWpnM09EUXhOamd5TlRjMk1qZzFORFV6TnpBM09EY3pORE0zTURjMU16YzBNREk=
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.1.148:9080
> Accept: */*
>
< HTTP/1.1 200 OK
< content-length: 423
< content-type: application/json
< date: Thu, 13 Jun 2019 02:34:09 GMT
< server: Cowboy
<
* Connection #0 to host 192.168.1.148 left intact
* Closing connection #
=>result as the following:
{
"code": 0,
"data": [
{
"datetime": "2019-06-13 10:33:13",
"node": "emqx@192.168.1.150",
"node_status": "Running",
"otp_release": "R21/10.3.2",
"sysdescr": "EMQ X Broker",
"uptime": "17 hours, 20 minutes, 54 seconds",
"version": "v3.1.0"
},
{
"datetime": "2019-06-13 10:33:13",
"node": "emqx@192.168.1.148",
"node_status": "Running",
"otp_release": "R21/10.3.2",
"sysdescr": "EMQ X Broker",
"uptime": "17 hours, 21 minutes, 28 seconds",
"version": "v3.1.0"
}
]
}
【温馨提示】
如果您觉得满意,可以选择支持下,您的支持是我最大的动力:
分享到:
相关推荐
Chapter 1, Getting Started with REST API, gives you an overview of what the REST API is, how it functions, and all that it is capable of doing. You will also find information about other platforms if ...
Rest apiRest apiRest apiRest apiRest apiRest apiRest apiRest api
ASA restapi文件
openshift-java-client, OpenShift REST API的Java客户端 OpenShift客户端 OpenShift REST API的Java客户端。 它几乎提供了 rhc-* 命令行 工具( 。创建/重命名域,创建/销毁应用程序,列出应用程序,列出可用墨盒,...
REST API Development with Node.js: Manage and Understand the Full Capabilities of Successful REST Development Manage and understand the full capabilities of successful REST development. REST API ...
H3C CAS REST API接口,支持系统集成和二次开发
python库。 资源全名:plone.restapi-7.5.0.tar.gz
Presto资源管理Rest API 文档
OpenDaylight REST API研究
arcgis server rest api离线文档
本资源包含网页和JAVA代码,分别演示基于百度语音合成REST API对接的POST方式提交接口数据,及其返回格式。网页格式直接返回语音,JAVA程序将POST调用返回的二进制数据流以字节流的方式存储在本地.mp3文件中。鉴于...
Learning WordPress REST API 英文mobi 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
该demo项目为采用SpringMVC方式,支持rest api的版本管理雏形
REST API设计原则。分标识、交互、元数据、表现等方面的设计
Activiti v7 REST API postman集合
Rest API设计规范指南
Total control rest api 脚本助手 : 1.rest api 模拟请求 2.rest api 基本操作 3.rest api 快速截图
现在很多主流平台采用rest方式的...于是乎简单封装下rest请求api(其实就是两个简单Java类,呵呵),可以实现http及https模式的请求,也支持JsessionId和代理模式,甚至系统自动发送邮件的功能也是用此工具类实现的.
Building a Rest API with Spring Building a Rest API with Spring
OpenAPI Specification 的目标是为 REST API 定义一个标准的、与语言无关的接口,允许人和计算机在不访问源代码、文档或通过网络的情况下发现和理解服务的功能。 通过 OpenAPI 的正确定义,消费者可以用最简答的...