我正在使用mosquitto和Eclipse PAHO Java客户端.
在普通的TCP套接字上一切正常.但现在我想使用SSL进行身份验证(不一定需要加密).
首先,我按照http://mosquitto.org/man/mosquitto-tls-7.html的说明进行操作
在mosquitto客户端我不能发布我的消息没有--insecure选项,意味着我必须
mosquitto_pub -h <server-ip> -p <port> -t "/topic1/test" -m "testmsg" --cafile ca_cert.pem --cert client.crt --key client_priv.key --tls-version tlsv1.2 --insecure
Run Code Online (Sandbox Code Playgroud)
否则,mosquitto控制台上会出现一个协议错误
1379576698: OpenSSL Error: error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown
1379576698: OpenSSL Error: error:140940E5:SSL routines:SSL3_READ_BYTES:ssl handshake failure
1379576698: Socket read error on client (null), disconnecting.
Run Code Online (Sandbox Code Playgroud)
- 不安全意味着不检查服务器证书主机名是否与远程主机名匹配.
对我来说有点奇怪的是我正在尝试TLS但是经纪人用SSL做出了回应.
但是我想在我的java paho客户端中启用SSL支持,我坚持这里的例子:https://gist.github.com/sharonbn/4104301
正如你在示例中所看到的那样
SSLContext context = SSLContext.getInstance("TLSv1")
Run Code Online (Sandbox Code Playgroud)
这是否意味着我正在尝试与TLSv1连接,对吧?不幸的是我得到了一个
javax.net.ssl.SSLHandshakeException: message_unknown
Run Code Online (Sandbox Code Playgroud)
我试图切换到TLSv1.2(因为它一直用mosquitto_pub为我工作)并改变了上下文
SSLContext context = SSLContext.getInstance("TLSv1.2")
Run Code Online (Sandbox Code Playgroud)
但后来我得到了
NoSuchAlgorithmException: Unknown protocol: …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Paho 的 MQTT javascript 客户端。我看到一个来自 HiveMQ 的例子,你可以在这里查看 - - http://www.hivemq.com/demos/websocket-client/
它似乎正在工作,但是当我将主机设置为:时test.mosquitto.org:1883,它是 mosquitto 的 mqtt 代理服务,它失败了。
当我尝试连接到这个 mosquitto 服务时,它给了我一个连接错误 - connect failed: AMQJS0007E, Socket error: undefined.
如何从安装在 Windows 中的 Mosquitto 代理获取消息计数,或者我们可以访问和查询代理数据库?
我正在我的Windows机器上运行MQTT服务器(mosquitto).该服务在端口号1883上运行.
从mosquitto.org下载mosquitto.js文件并进行如下调用当我调试时,我看到结果"connection.readyState == 0".如果我错过了什么,请帮助我.我正在使用chrome和safari最新版本来测试它.提前致谢.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/JavaScript" src="./js/mosquitto-1.1.js"></script>
<title>publisher</title>
</head>
<body>
<table align="center">
<tr>
<td>
<h1>Publisher</h1>
<table>
<tr>
<td><textarea rows="5" cols="25" id="txtMsg"></textarea></td>
</tr>
<tr>
<td align="center"><input type="button" value="post"
onclick="javaScript:postMessage();" /></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
<script type="text/javascript">
function postMessage()
{
var postVal = document.getElementById('txtMsg').value;
var t = new Mosquitto();
t.connect('ws://localhost',100000);
t.publish('inbox/msgrec',postVal,0,0);
}
Run Code Online (Sandbox Code Playgroud)
我是否有必要安装jetty服务器或使用node.js使用mosquitto javascript客户端进行连接,或者是否有必要在mosquitto安装中对配置文件进行任何更改.
我已经在这个环节中的说明安装了MQTT服务器"mosquitto"在我的Ubuntu机器https://lukeisadog.wordpress.com/2014/02/27/setting-up-mqtt-on-ubuntu-round-1/.但我无法测试服务器.当我输入mosquitto命令提示符时,我收到以下错误.
1431416111: mosquitto version 1.4.2 (build date 2015-05-09 21:39:32+0000) starting
1431416111: Using default config.
1431416111: Opening ipv4 listen socket on port 1883.
1431416111: Error: Address already in use
Run Code Online (Sandbox Code Playgroud)
当我输入时,mosquitto –daemon –verbose我收到的错误如"未知选项'-daemon'".请帮帮我.
我面临特定 client_id 断开连接的问题。当我尝试连接时,它会突然断开连接并显示错误
1450599983: New connection from 192.168.2.245 on port 1883.
1450599983: Client 46144 disconnected.
1450599983: New client connected from 192.168.2.245 as 46144 (c0, k60).
1450599984: Socket error on client 46144, disconnecting.
Run Code Online (Sandbox Code Playgroud)
我的conf.d文件是
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
cleansession true
Run Code Online (Sandbox Code Playgroud)
有时会在发送消息后发生。为什么会发生这种情况,我们该如何解决这个问题?
谢谢