Topic errors when publishing an event to MQTT - arduino

I'm using the pubsub library from an ESP8266 NodeMCU and the Arduino IDE.
https://github.com/knolleary/pubsubclient/tree/master/examples/mqtt_esp8266
My device is registered with the IBM Bluemix IoT Foundation (IoTF).
The client name I'm using is
char* myclient = "d:ORGID:Devicetype:Deviceid";
Where orgid is my orgID from Bluemix and the Device type and id are from the device I created and registered in the IoTF. The topic I'm posting to is by this line in my code:
client.publish("iot-2/evt/status/fmt/json", msg);
In Node-RED I have an IOT-in node looking at Device Status and using the Bluemix service for auth.
I am seeing this error when I put a debug node looking at the complete message object from the IoT-in node (note: I changed my orgid to ORGID in this debug output):
{
"_msgid": "9f433f7b.60bcc",
"deviceId": "InterConnect",
"deviceType": "nodeMCU",
"payload": {
"Action": "Disconnect",
"ClientAddr": "24.47.149.38",
"ClientID": "d:ORGID:nodeMCU:InterConnect",
"CloseCode": 276,
"ConnectTime": "2016-02-14T18:32:19.328Z",
"Port": 1883,
"Protocol": "mqtt4-tcp",
"ReadBytes": 111,
"ReadMsg": 0,
"Reason": "The topic is not valid.",
"SecureConnection": false,
"Time": "2016-02-14T18:32:19.397Z",
"User": "use-token-auth",
"WriteBytes": 4,
"WriteMsg": 0
},
"topic": "iot-2/type/nodeMCU/id/InterConnect/mon"
}
I'm wondering how my topic got changed to what it's showing here. Any ideas?

This was occurring because my code was subscribing to "iot-2/evt/command_id/fmt/format_string" instead of "iot-2/cmd/command_id/fmt/format_string" - once I fixed that, everything flowed fine.

Related

Can't create stack from template using Openstack Heat API

I'm trying to create a stack from a template using the Heat API. I'm using the API reference here as a guide. I have the following json in a file called single-server-template.json:
{
"stack_name": "api-test",
"template": {
"heat_template_version": "rocky",
"description": "Testing Heat API\n",
"resources": {
"server1": {
"type": "OS::Nova::Server",
"properties": {
"name": "Server1",
"image": "Ubuntu 22.04 (Jammy)",
"flavor": "alt.st1.small",
"key_name": "my_key",
"networks": "Internal"
}
}
}
}
}
I'm sending it with this: curl -X POST -H "X-Auth-Token:$OS_TOKEN" -d #single-server-template.json https://$OS_HOST_URL:8004/v1/$OS_PROJECT_ID/stacks
I've been at it for hours but no matter what I send I get a 400 error:
{"code": 400, "title": "Bad Request", "explanation": "The server could not comply with the request since it is either malformed or otherwise incorrect.", "error": {"type": "HTTPBadRequest", "traceback": null, "message": "The server could not comply with the request since it is either malformed or otherwise incorrect."}}
Things I've tried:
confirmed my environment vars are filled in correctly before sending
confirmed that the template itself is valid by spinning it up from the UI console
confirmed that other endpoints that require auth work as expected
screaming and/or crying
Can anyone confirm that what I've got is correct, or test it against your own openstack instance? The only other thing I can think of is that maybe my openstack provider has an issue with their API

can't push data from AWS IoT Core to AWS TimeStream

i finished 2 days trying to search and solve my problem but no result, i wish i can get some help from you.
i am pushing data from local pc running KEPServerEX to AWS IoT Core using MQTT Agent. i can see the data updating on AWS without issue. Then i created a DB and table on TimeStream called respectively Kep_DB & Table_Kep1.
my issue is that i am trying to create a Rule on AWS IoT Core to send data to the DB table. a rule to work it require to create an SQL like statement and Dimensions.
below what i have tried:
`SELECT (SELECT v FROM values) as value FROM 'iotgateway'`
Then as dimension i put 1 dimension like below:
name: id value: ${id}
my pyload on AWS IoT Core is having this format:
`{
"timestamp": 1668852877344,
"values": [
{
"id": "Simulation Examples.Functions.Random1",
"v": 7,
"q": true,
"t": 1668852868880
},
{
"id": "Simulation Examples.Functions.Ramp2",
"v": 161,
"q": true,
"t": 1668852868880
},
{
"id": "Simulation Examples.Functions.Sine4",
"v": 39.9302559,
"q": true,
"t": 1668852868880
}
]}`
I am still not able to see to data coming to my DB even i tried several dimension name and several SQL statement format.
Any experience on this please ?

Configuring retry policy for grpc request

I was trying to configure a retry policy from the client side for for some grpc services but it's not behaving the way I expect it to behave so I might be misunderstanding how retry policy works in grpc or there's a mistake in the policy. Here's the policy:
var retryPolicy = `{
"methodConfig": [{
"name": [{"service": "serviceA"}, {"service":"serviceB"}],
"timeout":"30.0s",
"waitForReady": true,
"retryPolicy": {
"MaxAttempts": 10,
"InitialBackoff": ".5s",
"MaxBackoff": "10s",
"BackoffMultiplier": 1.5,
"RetryableStatusCodes": [ "UNAVAILABLE", "UNKNOWN" ]
}
}]
}`
What I expected was that if the client's grpc request to a method defined in one the services(serviceA or serviceB) failed then I expect a retry and since waitForReady is true the client will block the call until a connection is available (or the call is canceled or times out) and will retry the call if it fails due to a transient error. But when I purposefully down the server which this request is going to. The client gets an Unavailable grpc status code and error is: Error while dialing dial tcp xx.xx.xx.xx:xxxx: i/o timeout but the client didn't get this error message 30 seconds later, instead received this error right away. Could the reason be because of how I'm giving the service names? Does it need the path of the file where the service is defined? For a bit more context, the grpc service is defined in another package which the client imports. Any help would be greatly appreciated.
Looking through the documentation, came across this link: https://github.com/grpc/grpc-proto/blob/master/grpc/service_config/service_config.proto and on line 72 it mentions
message Name {
string service = 1; // Required. Includes proto package name.
string method = 2;
}
I wasn't adding the proto package name when listing the services. So the retry policy should be:
var retryPolicy = `{
"methodConfig": [{
"name": [{"service": "pkgA.serviceA"}, {"service":"pkgB.serviceB"}],
"timeout":"30.0s",
"waitForReady": true,
"retryPolicy": {
"MaxAttempts": 10,
"InitialBackoff": ".5s",
"MaxBackoff": "10s",
"BackoffMultiplier": 1.5,
"RetryableStatusCodes": [ "UNAVAILABLE", "UNKNOWN" ]
}
}]
}`
where pkgA and pkgB are the proto package names.

Different payload in firebase notification between real device and simulator

I am using Flutter and I am experiencing a strange behavior when sending notification from the firebase cloud messaging console. If I send a notification to a real device, then the message I get is like this
on message {
google.c.sender.id: 801xxxxx873,
google.c.a.e: 1,
aps: {
alert: {title: Test 33, body: Test test 44}
},
gcm.n.e: 1,
google.c.a.c_id: 10xxxxxx18,
google.c.a.udt: 0,
gcm.message_id: 1592xxxxxxxx6906,
google.c.a.ts: 159xxxxx07
}
If I do the same on the ios simulator I get the following
on message {
from: 80xxxx873,
collapse_key: xxxxx.com.xxxx02,
notification: {
body: Test test 44, title: Test 33, e: 1, tag: campaign_collapse_key_559xxxxxxx002
}
}
Does anyone know why? I believe the first case is in line with apple documentation while the second one is the JSON structure I get when sending to Android
Is there a way to get the same JSON regardless if it is a real device or a simulator?
Thanks

fcm xmpp protocal "delivery_receipt_requested" param

I use fcm xmpp protocol send push and Receive delivery receipt。
but starting from 2019-12-18, delivery receipts have begun to decrease, and 2019-12-20 there are no receipts at all,
I don't know why. my params no change. it's my param.
<message id='q2fcQ-183429'><gcm xmlns="google:mobile:data">
{
"delivery_receipt_requested": true,
"notification": {
"sound": "default",
"tag": "1",
"title": "title",
"body": "body",
"click_action": "push.welcome",
"android_channel_id": "notification.default"
},
"time_to_live": 600,
"message_id": "02b16456eba3483782fc471e3dd2cf73",
"to": "xxxxxxxxxxx"
}
</gcm></message>
I also ran into this problem 2019-12-20. Firebase stopped notifying delivery of notifications by the flag "delivery_receipt_requested".
See updates from 12/17/2016 FCM:
FCM has removed ongoing support for delivery reciepts via the XMPP protocol. In place of XMPP delivery receipts, developers should enable delivery data export in the FCM client SDK.
https://firebase.google.com/support/releases
Also, Cloud Messaging version 20.1.0 - https://firebase.google.com/support/release-notes/android#messaging_v20-1-0
Added setDeliveryMetricsExportToBigQuery(boolean) and deliveryMetricsExportToBigQueryEnabled() to control and query if messsage delivery metrics are exported to BigQuery.

Resources