I am running my emqtt broker by docker image.
I am trying to catch all messages published on my broker and all acknowledged messages. For this purpose I am trying to use emq_web_hook plugin but when I enabled this plugin from dashboard, client disconnects and then unable to connect again to broker. I tried this with default configurations like
web.hook.api.url = http://127.0.0.1
web.hook.rule.client.connected.1 = {"action": "on_client_connected"}
web.hook.rule.client.disconnected.1 = {"action": "on_client_disconnected"}
web.hook.rule.client.subscribe.1 = {"action": "on_client_subscribe"}
web.hook.rule.client.unsubscribe.1 = {"action": "on_client_unsubscribe"}
web.hook.rule.session.created.1 = {"action": "on_session_created"}
web.hook.rule.session.subscribed.1 = {"action": "on_session_subscribed"}
web.hook.rule.session.unsubscribed.1 = {"action": "on_session_unsubscribed"}
web.hook.rule.session.terminated.1 = {"action": "on_session_terminated"}
web.hook.rule.message.publish.1 = {"action": "on_message_publish"}
web.hook.rule.message.delivered.1 = {"action": "on_message_delivered"}
web.hook.rule.message.acked.1 = {"action": "on_message_acked"}
I also changed the url and provide a url of my node server but it also dis not work.My endpoint was never called.
My dashboard is working but I am unable to publish.
What am I doing wrong or are there any steps I missed?
And How can I catch all those events?
I am confused. Documentation is not clear enough.
Thanks
Related
I have a Raspberry Pi Pico W that I am trying to get to communicate with AWS IoT, and after about 12-24 hours it seems to lose its connection. I have the keep alive set and I can see it's pinging the server. And then it suddenly stops. I'm going to add some code below to show the connection and stuff, but I'm baffled at this point (I am cross-posting this on other Raspberry Pi sites too). Any thoughts on why I can't keep the connection open?
import machine
import time
import ussl as ssl
from robust import MQTTClient
def sub_cb(btopic, bmsg):
global led
led = machine.Pin(15, machine.Pin.OUT)
topic = btopic.decode()
msg = bmsg.decode()
mqtt_message_json = ujson.loads(msg)
if 'desired' in mqtt_message_json['state']:
led_status_update = (mqtt_message_json['state']['desired']['led_status'])
if led.value() != str(led_status_update):
if led_status_update == '0':
print("turning off LED")
led.value(0)
elif led_status_update == '1':
print("turning on LED")
led.value(1)
DeviceID='PicoTestBed03'
PORT=8883
AWS_ENDPOINT={My AWS API End Point}
DISCONNECTED = 0
CONNECTING = 1
CONNECTED = 2
state = DISCONNECTED
KeepAliveSeconds = 60
led = machine.Pin(15, machine.Pin.OUT, value=1)
#Use Websockets
useWebsocket = False
#Create SSL Params object
#Assume the cert, key, and rootCA are all created correctly because my connection is successful
SSL_PARAMS = {'cert': cert, 'key': key, 'server_side': False, "cert_reqs":ssl.CERT_REQUIRED, 'cadata':rootCA}
#Create MQTT Client
client = MQTTClient(DeviceId, AWS_ENDPOINT, port=PORT, keepalive=KeepAliveSeconds, ssl=True, ssl_params=SSL_PARAMS)
#Connect MQTT Client
while state != CONNECTED:
try:
state = CONNECTING
print('AWS TEST: Trying to connect via MQTT...')
client.connect()
state = CONNECTED
except Exception as e:
print('AWS TEST: Could not establish MQTT connection')
continue
print('AWS TEST: MQTT LIVE!')
device_shadow_last_checked = time.localtime()
while 1:
if current_led_status != led.value():
current_led_status = led.value()
device_shadow_update_msg = b'{"state":{"reported":{"led_status":%d}}}' %(led.value())
mqtt_client.publish(led_status_shadow_topic_update, device_shadow_update_msg, qos=0)
if (time.mktime(time.localtime()) - time.mktime(device_shadow_last_checked)) >=60:
client.ping()
device_shadow_last_checked = time.localtime()
client.check_msg()
When trying a HTTP local execution to an device from a Google Nest hub, the hub restarts. Fullfillment, Discovery and identify are OK. The code used :
const deviceCommand = new smarthome.DataFlow.HttpRequestData();
deviceCommand.data = "";
deviceCommand.deviceId = device.id;
deviceCommand.isSecure = false;
deviceCommand.method = smarthome.Constants.HttpOperation.GET;
deviceCommand.port = 80;
deviceCommand.protocol = smarthome.Constants.Protocol.HTTP;
deviceCommand.requestId = executeRequest.requestId;
deviceCommand.path = "http://192.168.1.10/json.htm?command=On";
Thanks for any advice.
Fixed by using deviceCommand.path = "/json.htm?Command=On"
You should not include the entire target URL in the path argument, just the path portion. The DeviceManager API knows the target address of the device based on the deviceId and will construct the proper URL.
I would expect your command should look more like this (note I also removed a few extra properties you shouldn't need to include):
const deviceCommand = new smarthome.DataFlow.HttpRequestData();
deviceCommand.deviceId = device.id;
deviceCommand.isSecure = false;
deviceCommand.method = smarthome.Constants.HttpOperation.GET;
deviceCommand.port = 80;
deviceCommand.requestId = executeRequest.requestId;
deviceCommand.path = "/json.htm?Command=On";
I am making one iOS app communicating with Mqtt broker, mainly to publish message. But when I try to connect with broker using CocoaMQTT library it's always giving me error in connection.
I am trying with CocoaMQTT latest version and also 1.1.3 version. But both are failing in connection and giving me error
(Error Domain=kCFStreamErrorDomainNetDB Code=8 "nodename nor servname
provided, or not known" UserInfo={NSLocalizedDescription=nodename nor
servname provided, or not known})
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
let dateString = formatter.string(from: date)
let clientID = "smart-curtain-"+dateString
mqttClient = CocoaMQTT.init(clientID: clientID, host:
contantData.MQTT_BROKER_URL, port: UInt16(1883))
mqttClient.username = nil
mqttClient.password = nil
mqttClient.autoReconnect = true
mqttClient.allowUntrustCACertificate = true
mqttClient.keepAlive = 60
mqttClient.enableSSL = false
So its always ending up withmqttDidDisconnect delegate method. My broker url is tcp://xyz.com (xyz is just example) and port is 1883. I have tried 2-3 Mqtt toll apps from my iPhone to connect with broker detail, but no one able to connect it.
But same settings working fine in Android app. (it is using net.igenius:mqttservice:1.6.4) (this broker is no need authentication)
As shown in the CocoaMQTT doc, the host entry in the init method should be just the hostname, not a URI:
let clientID = "CocoaMQTT-" + String(NSProcessInfo().processIdentifier)
let mqtt = CocoaMQTT(clientID: clientID, host: "localhost", port: 1883)
mqtt.username = "test"
mqtt.password = "public"
mqtt.willMessage = CocoaMQTTWill(topic: "/will", message: "dieout")
mqtt.keepAlive = 60
mqtt.delegate = self
mqtt.connect()
e.g. should be xyz.com not tcp://xyz.com
var session = CocoaMQTT.init(clientID: "user1", host: "xx.xx.xxx.xx", port: 1883)
session.allowUntrustCACertificate = true
No need to send tcp://xx.xx.xxx.xx:port as in android, You can just pass xx.xx.xxx.xx by removing tcp:// and port number separately.
everyone.
I am trying to override dns resolver settings in my iOS app.
I used NEVPNManager to install a personal vpn and then used onDemandRules to set specific dns servers.
So far my code works for some domains.
Below is my code.
When I put "*.com" in matchDomains, it works perfectly.
But what I want to do is to redirect all dns queries to specific dns server.
I tried empty matchDomains([]) and empty string([""]).
I also tried wildcard expression like ["*"] and ["*.*].
So far I had no success.
It's been a few days and I still can't figure it out.
Can anybody tell me what I am missing here?
Thanks in advance.
let manager = NEVPNManager.sharedManager()
manager.loadFromPreferencesWithCompletionHandler { error in
if let vpnError = error {
print("vpn error in loading preferences : \(vpnError)")
return
}
if manager.protocolConfiguration == nil {
let myIPSec = NEVPNProtocolIPSec()
myIPSec.username = "username"
myIPSec.serverAddress = "server address"
myIPSec.passwordReference = self.getPersistentRef()
myIPSec.authenticationMethod = NEVPNIKEAuthenticationMethod.SharedSecret
myIPSec.sharedSecretReference = self.getPersistentRef()
myIPSec.useExtendedAuthentication = true
manager.protocolConfiguration = myIPSec
manager.localizedDescription = "myDNS"
let evaluationRule = NEEvaluateConnectionRule(matchDomains: ["*.com"], andAction: NEEvaluateConnectionRuleAction.ConnectIfNeeded)
evaluationRule.useDNSServers = ["XXX.XXX.XXX.XXX"]
let onDemandRule = NEOnDemandRuleEvaluateConnection()
onDemandRule.connectionRules = [evaluationRule]
onDemandRule.interfaceTypeMatch = NEOnDemandRuleInterfaceType.Any
manager.onDemandRules = [onDemandRule]
manager.onDemandEnabled = true
manager.enabled = true
manager.saveToPreferencesWithCompletionHandler { error in
if let vpnError = error {
print("vpn error in saving preferences : \(vpnError)")
return
}
}
}
}
I found this is buggy in even the latest iOS (10.3.1) and using NEVPNProtocolIKEv2. One moment it works, the next moment it doesn't want to start a VPN connection because it seems to misinterpret the ondemand rules and gives the error back saying the VPN profile is not enabled. I ended up with configuring the IKEv2 server (Strongswan) to push DNS settings with the "rightdns" option in /etc/ipsec.conf. This gives me the desired result of having the DNS requests redirected to a custom resolver.
Gerrit always show clone command like this :
The gerrit server i build view like this :
Is any plugin should be installed ? I already install download-commands plugin.
this is my gerrit.config file:
[gerrit]
basePath = git
serverId = 8f64957d-327a-4099-93ad-dc3f6fb598fa
canonicalWebUrl = http://192.168.1.188:8090
[database]
type = h2
database = /Users/wxkmac/Documents/gerrit/db/ReviewDB
[auth]
type = HTTP
#httpHeader = SM_USER
[receive]
enableSignedPush = false
[sendemail]
smtpServer = smtp.163.com
smtpServerPort = 465
smtpEncryption = ssl
smtpUser = xxx#163.com
smtpPass = xxxx
sslVerify = false
from=CodeReview<xxx#163.com>
[container]
user = xxx
javaHome = /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = proxy-http://192.168.1.188:7788/
[cache]
directory = cache
[download]
command = checkout
command = cherry_pick
command = pull
command = format_patch
scheme = ssh
scheme = http
scheme = anon_http
scheme = anon_git
scheme = repo_download
Some itens to check:
1) Make sure the donwloads-commands plugin is installed and running without issues
Check Plugins > installed
Check GERRIT-SITE/plugins
Restart Gerrit and check GERRIT-SITE/logs
2) Make sure you have set the download options in GERRIT-SITE/etc/gerrit.config
[download]
scheme = https
3) I think, in your case, you should set the sshd.advertisedAddress option
See more info here.