我正在尝试使用 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 代理获取消息计数,或者我们可以访问和查询代理数据库?
在Google Chrome上执行mqttws31.js作为HTML文件的一部分时,我遇到以下错误.
HiveMQ用作MQTT代理,日志如下
2014-10-28 14:46:45,043 INFO - HiveMQ home directory: E:\hivemq-2.1.0
2014-10-28 14:46:45,065 INFO - Starting HiveMQ Server
2014-10-28 14:46:48,249 WARN - No license file found. Using free personal licensing with restrictions to 25 connections.
2014-10-28 14:46:48,367 INFO - Activating statistics callbacks with an interval of 60 seconds
2014-10-28 14:46:48,368 INFO - Activating $SYS topics with an interval of 60 seconds
2014-10-28 14:46:48,728 INFO - Starting on address 127.0.0.1 and port 1883
2014-10-28 14:46:48,734 INFO - Started HiveMQ 2.1.0 in …
Run Code Online (Sandbox Code Playgroud) 我使用了 Paho Eclipse repo 中的 Android Service jar。在客户端连接后订阅任何主题时,我遇到了 NUllPOinterException。
public void connect(View view) {
MqttConnectOptions conOpt = new MqttConnectOptions();
String uri = "tcp://" + host + ":" + port;
boolean cleanSession = true;
// int timeout = 60 ;
// int keepalive = 60 ;
clientHandle = uri + clientId;
MqttAndroidClient client;
client = Connections.getInstance(this)
.createClient(this, uri, clientId);
Connection conn = new Connection(clientHandle, clientId, host, port,
this, client, sslConnection);
conOpt.setCleanSession(cleanSession);
// conOpt.setConnectionTimeout(timeout);
conOpt.setKeepAliveInterval(100);;
MqttCallbackHandler callback = new MqttCallbackHandler(this,
MainActivity.this, clientHandle); …
Run Code Online (Sandbox Code Playgroud) 我正在使用Paho MQTT
库,但我不知道如何知道我目前是否订阅了某个主题,以便不再订阅它.
有没有办法知道我订阅的特定主题是否?
我正在研究一个充当MQTT客户端的MVC应用程序.我正在使用paho的C#库M2Mqtt.基本上每当有人按下我网站上的按钮时,我想要发布一条消息,它也会收到一个答案(因此它也会订阅一个主题.)
我的问题是:当按下按钮(调用发布消息的ActionResult)时,我是否每次都必须连接到代理,或者是否有办法使连接保持活动状态(在Global中初始化它?)如何那样做呢?由于我对MVC/.net编程很陌生,所以我不熟悉所有的细节,并且很难自己解决这个问题.任何有关此事的帮助都非常感谢!:-)
var mosca = require('mosca')
var settings = {
port: 1884
};
//here we start mosca
var server = new mosca.Server(settings);
server.on('ready', setup);
// fired when the mqtt server is ready
function setup() {
console.log('Mosca server is up and running')
}
// fired whena client is connected
server.on('clientConnected', function(client) {
console.log('client connected', client.id);
});
// fired when a message is received
server.on('published', function(packet, client) {
if (packet.cmd === 'publish') {
//Qui uso mongo DB
console.log('Published: ', packet.payload.toString('utf8'));
}
});
// …
Run Code Online (Sandbox Code Playgroud) 我正在尝试连接到MQTT.js 的websocket 客户端,但无法与服务器握手。
我的代码:
<html>
<head>
<title>test Ws mqtt.js</title>
</head>
<body>
<script src="//unpkg.com/mqtt@2.5.0/dist/mqtt.min.js"></script>
<script>
var options = {
clientId: 'service-3Kx03pKnM2',
connectTimeout: 5000,
hostname: 'xxx.xxx.xxx',
port: 8000
};
var client = mqtt.connect(options);
client.on('connect', function () {
client.subscribe('presence');
client.publish('presence', 'Hello mqtt')
});
client.on('message', function (topic, message) {
console.log(message.toString());
client.end();
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我收到此错误:WebSocket connection to 'ws://broker.hivemq.com:8000/' failed: Connection closed before receiving a handshake response
。
如果我做错了什么,请告诉我。
我没有使用任何其他脚本 unpkg.com/mqtt@2.5.0/dist/mqtt.min.js
I created a program to receive data, recently.
And I want to break the loop When I receive a specific data.
For example, if I receive "1" to another machine, then my system will regard it as an illegal number, then it will break the loop to stop receiving data.
Here is my code in the below, and you can also see client.loop_stop()
in my code. But it not works.
I have also tried sys.exit()
in my code.
Although it …
我做了两台服务器,一台是虚拟测试服务器,另一台是我的django项目正在运行的地方。我可以在虚拟服务器上运行hivemq服务器,但在尝试在项目服务器上运行它时抛出错误。
java.lang.ExceptionInInitializerError: null
at org.jgroups.logging.LogFactory.getLog(Unknown Source)
at org.jgroups.blocks.MessageDispatcher.<init>(Unknown Source)
at b.a.a(Unknown Source)
at com.hivemq.HiveMQEnterpriseServer.b(Unknown Source)
at com.hivemq.HiveMQEnterpriseServer.a(Unknown Source)
at com.hivemq.HiveMQEnterpriseServer.main(Unknown Source)
Caused by: java.lang.NullPointerException: null
at java.base/java.util.Locale.<init>(Locale.java:713)
at java.base/java.util.Locale.<init>(Locale.java:742)
at org.jgroups.logging.Slf4jLogImpl.<clinit>(Unknown Source)
... 6 common frames omitted
Run Code Online (Sandbox Code Playgroud)