Google Cloud Messaging dont return Canonical ID - google-cloud-messaging

I have deliberately registered my app several times to GCM to test the canonical id concept, but the cloud doesnt return it to me. See my server log below, its the same device and I can see in the Android log that it received the message four times. But I never get a canonical id in return from Google, what is it I misunderstand?
[INFO com.bipper.filters.PushUpdatesFilter] method: POST childId: 13 has pending updates: true url: /mybipperapi/do/parents/1/children/13/usagelimits
[INFO com.bipper.services.gcm.GcmSenderService] registrationId: APA91bHQIWguRXvpVrg7Xh1nOsUqqbephClS9KkuuFf0eg3fkfgjkmvi1o-0WaSwWWdWwqXw9e3X80OsZwdINr1ufBjEXQJ5om48lL6q8bH3Vrlaf5U11FbyzQdVvzGy-3QBqahc_nMh9FeiL2sBzU0KPGG3y9xtYg
[INFO com.bipper.services.gcm.GcmSenderService] Sent message to one device: [ messageId=0:1349650679774901%d3cfcce76e2555b5 ]
[INFO com.bipper.services.gcm.GcmSenderService] registrationId: APA91bE9Vl_qijVdpFTqlJXA2OHyaF2cjKaCi8ZvNrD5r2woNs_TSuJgVuxn7RIF3pef6vdtd2MMV1TrWnusbGPXy4uWT4KJBhuAoAYgCjbXJduv-oz13_xICIKYOZTAFH2OpuC8E1Hw65KN6N4QukxG0W4Zor8jSg
[INFO com.bipper.services.gcm.GcmSenderService] Sent message to one device: [ messageId=0:1349650679857971%d3cfcce76e2555b5 ]
[INFO com.bipper.services.gcm.GcmSenderService] registrationId: APA91bEzQag9HBPbrR0wtaSuR3HA5NV795ZuDzxwQJVnQfc2r1lDv0gUXxc6GikUJDWMiUSge-b0BS1Tz2yIr8flpBqmAdpgQnatvP19PVm9zd8PopE51T-NJkfqqX65oPfKkx93Os7qS8_-IokjbyNIOK5FDCsrAQ
[INFO com.bipper.services.gcm.GcmSenderService] Sent message to one device: [ messageId=0:1349650679940798%d3cfcce76e2555b5 ]
[INFO com.bipper.services.gcm.GcmSenderService] registrationId: APA91bG_nVU-8VM9JSbTlxjAuseJ4LZG75BOoP5kd85garpcW698w4uwGWCy3dkUt3pXiXWhAV-KLPuEr-vw4_yARwjma2U46KXjmEoBwkTaVNi9t5M4sKRtqaKGZTcsaoa_Ng4EenVw41QFTi2At75946WR3Qu7jQ
[INFO com.bipper.services.gcm.GcmSenderService] Sent message to one device: [ messageId=0:1349650680044947%d3cfcce76e2555b5 ]
[WARN com.bipper.filters.PushUpdatesFilter] results has size 4, this is fishy
[INFO com.bipper.filters.PushUpdatesFilter] [ messageId=0:1349650679774901%d3cfcce76e2555b5 ]
[INFO com.bipper.filters.PushUpdatesFilter] [ messageId=0:1349650679857971%d3cfcce76e2555b5 ]
[INFO com.bipper.filters.PushUpdatesFilter] [ messageId=0:1349650679940798%d3cfcce76e2555b5 ]
[INFO com.bipper.filters.PushUpdatesFilter] [ messageId=0:1349650680044947%d3cfcce76e2555b5 ]
The documentation(link) says:
Canonical IDs
On the server side, as long as the application is behaving well,
everything should work normally. However, if a bug in the application
triggers multiple registrations for the same device, it can be hard to
reconcile state and you might end up with duplicate messages.
GCM provides a facility called "canonical registration IDs" to easily
recover from these situations. A canonical registration ID is defined
to be the ID of the last registration requested by your application.
This is the ID that the server should use when sending messages to the
device.
If later on you try to send a message using a different registration
ID, GCM will process the request as usual, but it will include the
canonical registration ID in the registration_id field of the
response. Make sure to replace the registration ID stored in your
server with this canonical ID, as eventually the ID you're using will
stop working.

When you parse the results from GCM, you have to manually check if it returns you a canonicalId.
String canonicalRegId = result.getCanonicalRegistrationId();
You then have to make sure this new id is used to push to the device.

As per Google docs,
When a plain-text request is successful (HTTP status code 200), the
response body contains 1 or 2 lines in the form of key/value pairs.
The first line is always available and its content is either id=ID of
sent message or Error=GCM error code. The second line, if available,
has the format of registration_id=canonical ID. The second line(containing canonical id) is
optional, and it can only be sent if the first line is not an error.
If there is a canonical id present, pgratton is right, you will have to parse the result and get it using result.getCanonicalRegistrationId();
Even after receiving a success response after pushing, canonical id can be null. In most cases, it will be null which means the token with which you pushed is OK and there is no need to replace it. When there is a change in the token (eg. in the case where Google refreshes the tokens) and if we still push with our old token, i guess you would then receive the canonical id in your response with which you must replace the old token.
If your push returns a failure response also, canonical id won't be present in the response.

Related

Am I able to view a list of devices by partition in iothub?

I have 2 nodes of a cluster receiving messages from iothub. I split their responsibility by partition. Node 1 reads from partitions 1,3,5,7,9 and the other 2,4,6,8, and 0. Recently, my partition 8 stops responding until I stop my code and restart it. It seems like a device is sending a message that locks up the partition. What I want to do is list all devices in my partition 8. Is that possible? Is there a cloud shell command to get those devices in a list?
Not sure this will help you, but you can see the partition on the incoming messages. For example you could use Azure Stream Analytics to see the partitions using this query:
Select GetMetadataPropertyValue(IoTHub, '[IoTHub].[ConnectionDeviceId]') as DeviceId, partitionId
from IoTHub
Also, if you run locally in VisualStudio it will tell you which device is sending malformed JSON. eg.
[Warning] 10/21/2021 9:12:54 AM : User Warning Source 'IoTHub' had 1 occurrences of kind 'InputDeserializerError.InvalidData' between processing times '2021-10-21T15:12:50.5076449Z' and '2021-10-21T15:12:50.5712076Z'. Could not deserialize the input event(s) from resource 'Partition: [1], Offset: [455266583232], SequenceNumber: [634800], DeviceId: [DeviceName]' as Json. Some possible reasons: 1) Malformed events 2) Input source configured with incorrect serialization format
Also check your "Activity Log" blade in the ASA job. It may have more details for you.

UI5 Odata batch update - Connect return messages to single operation

I perform a batch update on an OData v2 model, that contains several operations.
The update is performed in a single changeset, so that a single failed operation fails the whole update.
If one operation fails (due to business logic) and a message returns. Is there a way to know which operation triggered the message? The response I get contains the message text and nothing else that seems useful.
The error function is triggered for every failed operation, and contains the same message every time.
Maybe there is a specific way the message should be issued on the SAP backend?
The ABAP method /iwbep/if_message_container->ADD_MESSAGE has a parameter IV_KEY_TAB, but it does not seem to affect anything.
Edit:
Clarification following conversation.
My service does not return a list of messages, it performs updates. If one of the update operations fails with a message, I want to connect the message to the specific update that failed, preferably without modifying the message text.
An example of the error response I'm getting:
{
"error":{
"code":"SY/530",
"message":{
"lang":"en",
"value":"<My message text>"
},
"innererror":{
"application":{
"component_id":"",
"service_namespace":"/SAP/",
"service_id":"<My service>",
"service_version":"0001"
},
"transactionid":"",
"timestamp":"20181231084555.1576790",
"Error_Resolution":{
// Sap standard message here
},
"errordetails":[
{
"code":"<My message class>",
"message":"<My message text>",
"propertyref":"",
"severity":"error",
"target":""
},
{
"code":"/IWBEP/CX_MGW_BUSI_EXCEPTION",
"message":"An exception was raised.",
"propertyref":"",
"severity":"error",
"target":""
}
]
}
}
}
If you want to keep the same exact message for all operations the simplest way to be able to determine the message origin would be to add a specific 'tag' to it in the backend.
For example, you can fill the PARAMETER field of the message structure with a specific value for each operation. This way you can easily determine the origin in gateway or frontend.
If I understand your question correctly, you could try the following.
override the following DPC methods:
changeset_begin: set cv_defer_mode to abap_true
changeset_end: just redefine it, with nothing inside
changeset_process:
here you get a list of your requests in a table, which has the operation number (thats what you seek), and the key value structure (iwbep.blablabla) for the call.
loop over the table, and call the method for each of the entries.
put the result of each of the operations in the CT_CHANGESET_RESPONSE.
in case of one operation failing, you can raise the busi_exception in there and there you can access the actual operation number.
for further information about batch processing you can check out this link:
https://blogs.sap.com/2018/05/06/batch-request-in-sap-gateway/
is that what you meant?

Amazon Marketplace Web Service create inbound shipment NOT_ELIGIBLE_FC_FOR_ITEM, what wrong?

step 1:
request create inbound shipment plan api.
http://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_CreateInboundShipmentPlan.html
response:
[
//usualy 1-5 plan has been reply,no any one plan contain full of my items.
//the plan 1
{
"ShipToAddress": {
... ignore address detail
},
"ShipmentId": "FBA15CQQTFFM",
"DestinationFulfillmentCenterId": "PHX3",
"LabelPrepType": "NO_LABEL",
"Items": [
//item list, it is alway not full of my provide items.
{}
]
},
//the plan2, and more plan
{},{},...
]
step 2:
choose max count items of plan for create inbound shipment.
i cant edit item in this step.
http://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_CreateInboundShipment.html
step 3:
update inbound shipment plan for add all of item to this plan.
http://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_UpdateInboundShipment.html
request url: https://mws.amazonservices.com/FulfillmentInboundShipment/2010-10-01
request params:
SellerId=xxxxxxxxxxxxxxxxxx
AWSAccessKeyId=xxxxxxxxxxxxxxxxxxx
SignatureVersion=2
SignatureMethod=HmacSHA256
Version=2010-10-01
InboundShipmentHeader.ShipmentStatus=WORKING
ShipmentId=FBA15CR0QLLR
InboundShipmentHeader.ShipmentName=2018-05-16-AAA
InboundShipmentHeader.ShipFromAddress.Name=Wang%20Jingang
InboundShipmentHeader.ShipFromAddress.AddressLine1=396haozhiyihao
InboundShipmentHeader.ShipFromAddress.AddressLine2=
InboundShipmentHeader.ShipFromAddress.City=Guangzhou
InboundShipmentHeader.ShipFromAddress.DistrictOrCounty=
InboundShipmentHeader.ShipFromAddress.StateOrProvinceCode=Guangdong
InboundShipmentHeader.ShipFromAddress.CountryCode=CN
InboundShipmentHeader.ShipFromAddress.PostalCode=510080
InboundShipmentItems.member.1.SellerSKU=A71231811510311-
InboundShipmentItems.member.1.QuantityShipped=20
InboundShipmentItems.member.2.SellerSKU=A5W3E3112HE0
InboundShipmentItems.member.2.QuantityShipped=80
InboundShipmentItems.member.3.SellerSKU=A71231811540010-
InboundShipmentItems.member.3.QuantityShipped=20
InboundShipmentItems.member.4.SellerSKU=A71231811540011-
InboundShipmentItems.member.4.QuantityShipped=30
InboundShipmentItems.member.5.SellerSKU=A71231811515411-
InboundShipmentItems.member.5.QuantityShipped=20
InboundShipmentItems.member.6.SellerSKU=J8S109225HE90
InboundShipmentItems.member.6.QuantityShipped=10
InboundShipmentItems.member.7.SellerSKU=J8S109225HE92
InboundShipmentItems.member.7.QuantityShipped=33
InboundShipmentItems.member.8.SellerSKU=J8S109225HE93
InboundShipmentItems.member.8.QuantityShipped=10
InboundShipmentItems.member.9.SellerSKU=J8S109225ND90
InboundShipmentItems.member.9.QuantityShipped=8
InboundShipmentItems.member.10.SellerSKU=J8S109225ND91
InboundShipmentItems.member.10.QuantityShipped=12
InboundShipmentItems.member.11.SellerSKU=J8S109225ND92
InboundShipmentItems.member.11.QuantityShipped=17
InboundShipmentItems.member.12.SellerSKU=J8S109225ND93
InboundShipmentItems.member.12.QuantityShipped=14
InboundShipmentItems.member.13.SellerSKU=J8S109225ND94
InboundShipmentItems.member.13.QuantityShipped=5
InboundShipmentItems.member.14.SellerSKU=J8S109225QC90
InboundShipmentItems.member.14.QuantityShipped=10
InboundShipmentItems.member.15.SellerSKU=J8S109225QC91
InboundShipmentItems.member.15.QuantityShipped=5
InboundShipmentItems.member.16.SellerSKU=J8S109225QC92
InboundShipmentItems.member.16.QuantityShipped=9
InboundShipmentHeader.AreCasesRequired=false
Action=UpdateInboundShipment
Timestamp=2018-05-18T13%3A08%3A04%2B08%3A00
Signature=LCFu1NoX1QnENH1oCFEbwsXy1JVh7QNjpe2enGj258Q%3D
sometime success.
sometime fail, and tell me [skuType=MSKU, sku=..., reason=NOT_ELIGIBLE_FC_FOR_ITEM.]
do not change anything.
replicated 1-3.
sometime success.
sometime fail, and tell me [skuType=MSKU, sku=..., reason=NOT_ELIGIBLE_FC_FOR_ITEM.]
imcomprehensible it is, sku maybe not equal with last time. it is random, maybe one, mabe two.
can you tell me waht wrong?
HOW CAN I TO DO, MAKE ALL ITEMS IN ONE PLAN?
I got the sam error before, I found a ref.:
https://help.scanpower.com/support/solutions/articles/11000037578-what-does-the-not-eligible-fc-for-item-error-mean-
FYI, sure, I have a SKU, when creating inbound shipment, to old account, it's OK, but to new account, API will reponse the error you said.
Unfortunately, this error is coming directly from Amazon. There is a product in your shipment that is causing a conflict with the inbound shipping and/or the fulfillment center, but Amazon does not give us any indication as to the specific issue.
We have contacted Amazon and they suggest each seller experiencing this issue contact Seller Support for more information on the error. Please let them know that you are listing said item(s) via their MWS API and are receiving the following message: (insert the text of YOUR SPECIFIC ERROR MSG HERE what you see below is an example)
Invalid Items found - ShipmentId [FBA53HXYFX] MerchantCustomerId [A2WOJIKNACJWE4] InvalidItems[ (skuType=MSKU, sku=2016-11-30-B0006SGYS8-1099, reason=NOT_ELIGIBLE_FC_FOR_ITEM)]Shipment Id: FBA53HXYFXRequest Id: fb04a1f9-721f-4be3-a9c7-ba4063c13f69

WSO2 API Manager returning RunTime Error

I have an API in WSO2. When I try to test it in the store with valid parameters via GET, it returns the following error message:
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>101504</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Send timeout</am:description>
</am:fault>
I have already searched and tried a lot, but with no success, always returning the same error. Don't know if helps, but the api that I try to access is a PHP file.
Any ideas?
EDIT:
I have identical apis to this one, changing only the response, that are working properly. Even if I erase the php file that the API is pointing, the error keep coming.
EDIT:
I changed the code in Management Console, in Metadata>List>APIs:
{"production_endpoints":
{"url":"http://site/myapi.php","config":
{"format":"leave-as-is","optimize":"leave-as-
is","actionSelect":"fault","actionDuration":30000}},
"sandbox_endpoints":
{"url":"http://site/myapi.php","config":
{"format":"leave-as-is","optimize":"leave-as-
is","actionSelect":"fault","actionDuration":30000}},
"implementation_status":"managed","endpoint_type":"http"}
to this:
{"production_endpoints":
{"url":"http://10.20.40.189/ConsultaAutorizacaoCadPos.php","config":null},
"sandbox_endpoints":{"url":"http://10.20.40.189/ConsultaAutorizacaoCadPos.php","config":null},
"implementation_status":"managed","endpoint_type":"http"}
And this error message vanishes. But this new one appears:
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>303001</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Currently , Address endpoint : [ Name : admin--myapi_APIproductionEndpoint_0 ] [ State : SUSPENDED ]</am:description>
EDIT: this error message is appearing just sometimes. Most of the time the request takes long time to run and then returns nothing( no content )
Any ideas how to solve it?

Pepper robot goes charging successfully and leaves it successfully but after that it will not go charging again

So I got Pepper robot charging working smoothly for 1 interval. I did it by creating a loop of calling out goToStation() until it returns 0. Before it i deactivated the topic and also paused awarness with pauseAwareness();
When it went successfully to station i activated dialog topic again and then resumed awareness. All the other features worked well after that. Then i called Pepper to leave the station and it did successfully. Now when i want pepper to go to the charging station again it will just deactivate the topic, pause awareness but will not go to station.
Logs end here for unsuccessful going back to charging
[WARN ] audio.NuanceVoconEngine :xLhNmspConnectionEventCallback:0 Nuance Remote: Connection Failed.
[INFO ] audio.NuanceVoconEngine :xLhNmspConnectionEventCallback:0 eventType: 1 eventValue: 5 reason: 10 sessionId: <null> message: Disconnected.
[INFO ] Dialog :connectionChanged:0 Connection changed: 0
[WARN ] ConditionChecker :onEvent:0 Event queue is empty!
enter code here
In the first attempt of charging that goes successfull logs look like this after that.
[INFO ] audio.NuanceVoconEngine :xLhNmspConnectionEventCallback:0 Nuance Remote: Connection Established.
[INFO ] Dialog :connectionChanged:0 Connection changed: 1
[INFO ] audio.NuanceVoconEngine :xLhNmspConnectionEventCallback:0 eventType: 3 eventValue: 1 reason: 10 sessionId: db6dafbe-65d4-4348-8420-e772560e9fce message: <null>
...... (these logs continiue with alrecharge manager doing the job)
What could be the cause of it working the first time using it and then next time it will just not work?