GCM response results has more items than request registration_ids - google-cloud-messaging

We send such payload into GCM server
{"data":{"title":"Unlimited Music Ringtones for 24hrs!","p":"5;"},"registration_ids":["APA91bF2U2KaLF173wyqUWfyxKw_xJI4fW22MKRUuoG3E6uubO-a4F9_SS0byscd5YwbbQZsgCsuxmI_IYINZOGRonMH64hZrhDqeqa0a5ixrnhPvcLGGIrIm-J624TCwZFtVktPypyr"],"time_to_live":43200}
But in response we get 9 result items
{"multicast_id":6634278235585666161,"success":1,"failure":8,"canonical_ids":0,"results":[{"error":"NotRegistered"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"message_id":"0:1443085201594600%341e1321f9fd7ecd"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"error":"NotRegistered"}]}
Issue reproduced from time to time. This is undefined behaviour? How to determine which response it corresponding to register_id?
P.S. We used persistent connection

Related

TimedOut in python-telegram-bot but message is sent

I've got following error while trying to send a message to a specific telegram channel:
TimedOut: Timed out
The read operation timed out
the method which I used from python-telegram-bot was send_message.
Although my bot got this error but it still sent the message to the channel and because I did not catch that exception all data from the message was lost but I really need to remove my messages from that channel after a specific period of time.
Is this OK that the bot sent the message even though it got Timed Out? How can I prevent this from happen again or remove this kind of messages from the channel after being sent?
Time out errors mean that TG didn't send a response to your send_message request quick enough. It does not necessarily mean that the request wasn't processed - that's why the message may still be sent. However, without response from TG, you don't have the message id of the resulting message and it will be hard to impossible to delete it.
You can try to increase the time that PTB waits for a response from TG. THis can be done in different ways:
with the timeout parameter of send_message
with Defaults.timeout, if you're using PTBs Defaults setup
by specifying it via the request_kwargs that you pass to Updater
You may want to have a look at this wiki page on networking.
Disclaimer: I'm currently the maintainer of python-telegram-bot
After a couple of hours reading here and there, and passing timeout=30 to context.bot.send_audio and getting an error that says unknown parameter even though send_audio's docs clearly states it takes a timeout param, I found that you can fix this by passing the timeouts to the Application upon building it:
application = ApplicationBuilder()
.token(bot_data["token"])
.read_timeout(30)
.write_timeout(30)
.build()
This fixed my bot. Hope this helps you as well.

Worklight - Don't propagate error details to client

I would like to know if IBM Worklight has out of the box support for not propagating the error details to the client in the response.
To illustrate, let's suppose that while processing a request, per some reason something went wrong and the server responds it with a body similar to:
{"errors":["Some exception/error details go here..."],"isSuccessful":false,"warnings":[],"info":[]}
However, I don't want the consumer to be aware of the such details, neither to inflate my response with it. Does IBM Worklight provide any way to change such behaviour and, for example, send the errors array empty or at least to transform it before sending the response to the client?
Worklight server responds to requests from the client. Depending on the case, this may be a valid response to the request or an error message, in case something did not go as per plan. Note that in this case, the response flow enters the failure callback of the listener.
The error message is passed back in a format understood by the developer such that they can account for these and take corrective actions. This message is not intended for the end user, but for the developer to handle. In case the message is too descriptive ( or too technical), it is left to the developer to show a generic or proper message.
For example, instead of "An exception was thrown because the input parameter is wrong" can be presented to the end user as "Please verify your input..." .
In case the error is resulting from the adapter - when adapter receives an error from the backend, it can be checked and modified at the adapter, before passing back to the client. Similarly, if errors from exceptions at the adapter can be caught and handled, custom responses can be sent back to the client.
If the error results from exceptions or other conditions, Worklight server cannot be configured to the send errors array empty or transform the response before sending the response to the client. This is for the developer to handle at client side.

Iot Hub - default event hub receive same message twice

I'm having APi Service that handle some information from my device. After that i use default Iot-HUB SDK that allows me to send data into Iot-Hub. In my event hub I usually get data that I send more than once. Is there any options to see what it happens ? Maybe some extra settings that to retransmission or something that send messages more than once from my web api service ?
I had the same problem with my code. I was sending messages to an iothub using an Azure function. I had the message sending time trigger as a variable. When sending messages in shorter frequencies (i.e. messages that are sent each second) some of these messages are duplicated.
By changing the message protocol it solved. Given below is the corrected code,
DeviceClient deviceClient = DeviceClient.CreateFromConnectionString(connectionString, TransportType.Http1);

Is there a way to add header to apache response on how long it took to retrieve a resource?

Is there a module or a built-in function in apache which I can use/activate to send information how long it took to retrieve/process a resource?
For example the resource http://dom.net/resource is accessed. The response header will include the total time it took to wait for the resource to be ready before it gets sent back to the client.
Apache doesn't really 'wait' until the resource is ready before sending the response back to you - it streams data back to the client as and when it receives it.
Depending on what you're interested in measuring, you could record the time taken for the client to receive the first byte/last byte back from Apache, or measure the time taken for Apache to receive the first byte from the (remote?) resource like so. The time taken for Apache to receive the entire response back from the remote resource is not something you can send in the headers, as the headers will have been sent to the client before the remote response is fully received. This information could trivially be written to the Apache logs, however.

Http Status 200 to response back to third party

I am currently working on the payment gate way which connects to Third Party Payment API by giving some information including return_url (that they will send the payment result back) and notify_url (that send the same information as in return_url in case there are some issues with the cardholders' internet connection or issues with their browser).
After processing at their end, my end processed return page and notification page successfully.
But they said as follows.
Merchant would have to response with HTTP 200 OK to indicate that the notification is received successfully.
They would retry (up to 5 times) to resend the notification again if HTTP 200 OK response is not received after specific timeout (currently is fixed to 60 seconds timeout).
So I put the following codes in the notification page.
If Response.StatusCode <> HttpStatusCode.OK Then
Response.StatusCode = HttpStatusCode.OK
End If
I think this snippets aren't enough because they are still calling to my notification page 4 times.
I check the log tables. Although the process is complete, the log are still coming in after some interval.
Anybody can help about to response with HTTP Status 200 .
Any suggestion are appreciated.