Trying to send FCM but sometimes it shows 400 - firebase-cloud-messaging

I tried to send FCM message with this JSON:
{"data":{"before_end":"-941.813993","before_start":"341.813993","ended_at":"1480427700","id":"5","now":"1480426758","started_at":"1480427100","subtype":"in10","type":"chat_schedule"},"to":"/topics/13_notif","registration_ids":["ffM9IdvHBmY:APA91bF2LEUfxv_S8tmjfQccQR8VW_Yx9Zp25rrLbkIc9WnMeBh2tRfdMcDPsFqA6uqnIKFWLAygrVcr-98_krTikm8GeYC41kha-eoZ987HhPmbJNT7Eeo-UyHr7hJ6grS9PEm7q1ep","fgKJA8e2U_o:APA91bG09ZnKjNZxpnZmthmX5MR1A-hD3nepqCz0HesckF2HU6nS8MFJYbNX_OUH33ep6ZedN8UPy8AtSWQj4pkSrNTqPRb8pDGxhjSljpr-DvJ_7nwlAXc2SiNsV-XtNq4nfc8tZaqq","dlubMvP6e1k:APA91bEOmnkELD9HdlQMMPBm2KwWaiku7WpOixDzpAALr7VFO5sWQAkJjbYYphdLAV_4Hqlh8_9ixraebA3hn6I3CemLmqpnnR67jYq5fjtpTUqKldO6dtiZSMBZ6E9aZdwrrPxf_gUW","cKD8A2Rp2iw:APA91bF86nwk_SZIyVdymyiNgiTGlEr8YX4P44Hv7QXv6FcYyvswBV0mnYTbCEkj8dUAusPB8FXoC_9r0b9U1bNh7DScfUEHlF9KjHzynnwtyUmP0nCaWBBCW4CYn1YK01y_8uWAoPTJ","elN6OMhyhJ8:APA91bEQjALiSwtOzI84U9h5VgTji_pqBqF61K3By7-3u4cn_WQZSay9NkqXK4sSzj1wk6AsBhlD5wvQXmrddBn54mlAq5OeXA88fX0zGpx-nO6i2FtQ8OHyI8TwuASj2QrB7IFYkrxU"],"notification":{}}
but sometimes it shows 400 in the response struct:
&fcm.FcmResponseStatus{
Ok: false,
StatusCode: 400,
MulticastId: 0,
Success: 0,
Fail: 0,
Canonical_ids: 0,
Results: nil,
MsgId: 0,
Err: "",
RetryAfter: "",
}
After I google it for a while, 400 means:
400 Only applies for JSON requests. Indicates that the request could not be parsed as JSON, or it contained invalid fields (for instance, passing a string where a number was expected). The exact failure reason is described in the response and the problem should be addressed before the request can be retried.
For other json, it wasn't showing 400:
{"data":{"before_end":"2613","before_start":"-4074","ended_at":"1480424100","id":"5","now":"1480426713","started_at":"1480422639","subtype":"in-1","type":"chat_schedule"},"to":"/topics/13_notif","notification":{}}
The response was:
&fcm.FcmResponseStatus{
Ok: true,
StatusCode: 200,
MulticastId: 0,
Success: 0,
Fail: 0,
Canonical_ids: 0,
Results: nil,
MsgId: 5721749585709774290,
Err: "",
RetryAfter: "",
}
What could possibly wrong?

Nevermind, I shouldn't have use both registration_ids and to on the JSON.
On more detail github.com/NaySoftware/go-fcm may not be reused to send a broadcast topic then regids or vice versa, we must use different client or the To and RegistrationIds must be cleared first before can be reused.

Related

The timeout was reached before the message could be written to the output buffer

I'm trying to connect to the AWS Redis instance via the below c# code.
var option = new Microsoft.Extensions.Caching.StackExchangeRedis.RedisCacheOptions
{
ConfigurationOptions = ConfigurationOptions.Parse("master.test-redis-cluster.89run.use1.cache.amazonaws.com:6379,ssl=true,sslProtocols=Tls,abortConnect=false"),
InstanceName = "testapi",
};
IDistributedCache distributedCache = new RedisCache(option);
distributedCache.SetAsync("testKey", System.Text.Encoding.UTF8.GetBytes("testData"));
When I'm trying to set the value in the cache, I'm getting the below error. Though there is enough Threads, i'm getting this error.
{
"Redis-Message": "HMGET testapi1fb31d10-ebee-4f39-9a73-9bc8901461e5",
"Redis-Timeout": "5000",
"Redis-OpsSinceLastHeartbeat": "0",
"Redis-Queue-Awaiting-Write": "0",
"Redis-Queue-Awaiting-Response": "0",
"Redis-Active-Writer": "False",
"Redis-Backlog-Writer": "CheckingForTimeout",
"Redis-Server-Endpoint": "master.test-redis-cluster.89run.use1.cache.amazonaws.com:6379",
"Redis-Multiplexer-Connects": "1/1/0",
"Redis-Manager": "10 of 10 available",
"Redis-Client-Name": "testapi-app-deployment-7674cf88nnl5(SE.Redis-v2.6.70.49541)",
"Redis-ThreadPool-IO-Completion": "(Busy=0,Free=1000,Min=16,Max=1000)",
"Redis-ThreadPool-Workers": "(Busy=0,Free=32767,Min=16,Max=32767)",
"Redis-ThreadPool-Items": "(Threads=16,QueuedItems=0,CompletedItems=495)",
"Redis-Busy-Workers": "0",
"Redis-Version": "2.6.70.49541",
"redis-command": "HMGET testapi1fb31d10-ebee-4f39-9a73-9bc8901461e5",
"redis-server": "master.test-redis-cluster.89run.use1.cache.amazonaws.com:6379",
"ex_msg": "The timeout was reached before the message could be written to the output buffer, and it was not sent, command=HMGET, timeout: 5000, inst: 0, qu: 0, qs: 0, aw: False, bw: CheckingForTimeout, serverEndpoint: master.test-redis-cluster.89run.use1.cache.amazonaws.com:6379, mc: 1/1/0, mgr: 10 of 10 available, clientName: testapi-app-deployment-7674cf88nnl5(SE.Redis-v2.6.70.49541), IOCP: (Busy=0,Free=1000,Min=16,Max=1000), WORKER: (Busy=0,Free=32767,Min=16,Max=32767), POOL: (Threads=16,QueuedItems=0,CompletedItems=495), v: 2.6.70.49541 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)"
}
Not able to figure out why.
Since there is no connection error, it seems the code was able to connect to Redis. Also in error payload size is not there so again huge payload size possibility is ruled out.
Please note:
There are many similar questions in stack overflow and tried all of them. But, no luck.
We recently updated our API from .net 3.1 to 6. After this, we started to face this issue, and currently, API is not working at all. There is a sufficient number of threads and works I can see. Also we tried by increasing the timeout but again no luck.

HTTP 500 on Podio GET item

When fetching GET https://api.podio.com/item/1259778758 (other items work fine), I get the following error:
HTTP 500
with response body:
{
"error_parameters": {},
"error_detail": null,
"error_propagate": false,
"request": {
"url": "http://api.podio.com/item/1259778758",
"query_string": "",
"method": "GET"
},
"error_description": "An unexpected error occured during execution",
"error": "unexpected"
}
I assume this is due to some field value, but cannot figure this out. Can you please check an fix this?
Additional notes:
It is not possible to open this item in the browser as well
The filter operation in the API fails as well when this item is in the result.
It sounds like this should be escalated with Podio technical support.

how to fix 'InvalidRegistration' FCM

I'm getting the InvalidRegistration error in response of my post request for sending push notification.
When I use the Firebase console to send push notification it works all fine.
so I copy the exact registration token I've used in console. I also get my api-key from my project-settings/cloud-messaging.
for sending the post request I've used postman.
I've sent my post request to https://fcm.googleapis.com/fcm/send
my postman header has this attributes:
key: Authorization value: key=<api-key-i-got-from-console>
key: Content-Type value: application/json
my body is:
{
"to" : "fDj8iG5ajZI:APA91bHfs_AjdxOc5Qn-1Plr_OfitrdCTchb4syhPGC0DhPMGiWggJ9mQ5W00ombqowlUSCUOfH_0N3KA-KF0VjQvj5mcMNUMUBgTblpsNzra60kwrbtH2ikfdBa8lenh__olBpGZD4O'",
"collapse_key" : "type_a",
"notification" : {
"body" : "plz work",
"title": "title"
},
}
I get this response from the Firebase
{
"multicast_id": 5801302802423881516,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
{
"error": "InvalidRegistration"
}
]
}
I did the same with fcm and django-push-notification and got the same result I have no clue what am I doing wrong since my token works with the console and I can send push notifications from the console.
it was my bad that I had an extra ' in the end of my token...

Handle unavailable server with vue-resource

Is there a way to handle errors with vue-resource when a HTTP response has not been received?
For example, when the backend server is unavailable (i.e. http://localhost:30000 doesn't exist) I receive the following error in Safari:
[Error] Failed to load resource: Could not connect to the server. (create, line 0)
However the vue-resource response object passed to the error callback is empty (doesn't give any indication about the failure to connect to the server):
{ "url": "http://localhost:30000", "ok": false, "status": 0, "statusText": "", "headers": { "map": { "": [ "" ] } }, "body": null }
What is the best way to handle this? Hardcoding for a status === 0 seems like it might be overly generic?

Yodlee process MFA with null mfaInfo.fieldInfo

According to
https://developer.yodlee.com/Aggregation_API/Aggregation_Services_Guide/API_Flow/Refresh_Account
once I've received response with isMessageAvailable = true and errorCode is empty I should call getMFAResponse (actually I'm using getMFAResponseForSite)
this response should contain not null mfaRefreshInfo.fieldInfo. Unfortunately all cases I was able to test fieldInfo were null.
Could you please help me to understand what I'm doing wrong. SiteAccountId is 10038630.
If you are using getMFAResponseForSite then use this refresh flow
Now response of getMFAResponseForSite depends upon how soon yodlee encounters the MFA after login attempt.
There are 3 types of responses you can get -
{ "isMessageAvailable": false, "timeOutTime": 0, "itemId": 0,
"memSiteAccId": 10000502, "retry": true }
On your 1st call to the MFA API you may get this if there is a delay in bringing the MFA data , hence you need to go back and call this API again (as suggested in the flow to loop).In this case if with messageAvailable if false and timeoutTime > 0 then it means that Yodlee has timed out the request and you can abort the refresh and try re-initiating it.
{
"isMessageAvailable": true,
"fieldInfo": {
"responseFieldType": "text",
"minimumLength": -1,
"maximumLength": 6,
"displayString": "Security Key"
},
"timeOutTime": 97640,
"itemId": 0,
"memSiteAccId": 10000052,
"retry": false
}
This is the case where you get the MFA response. Here you can see that isMessageAvailable is true and you have field info populated. This response can come at 1st call of getMFAResponseForSite or after 1 or 2 loops.
{
"isMessageAvailable": true,
"fieldInfo": {
"questionAndAnswerValues": [],
"numOfMandatoryQuestions": -1
},
"timeOutTime": 98480,
"itemId": 0,
"errorCode": 0,
"memSiteAccId": 10039332,
"retry": false
}
In this case you can see that there is an error code present, if it's 0(zero) that means login was successful without MFA and Yodlee is able to navigate to account summary page. In case error code is non zero then please refer error code page
Now in your case the siteAccountID is failing with error code 429 and hence you should be getting that information in getMFAResponseForSite API.
can you make sure you are following the right refresh flow and making the right API calls as ideally the behavior will not change from what is represented in the flow diagram.