PouchDB over HTTP disconnects on inactivity after some minutes? - couchdb

I am trying to create an application that uses PouchDB as an adapter to a CouchDB running on a server.
Problem: After some minutes of inactivity I get the following error on trying to access the database again:
{
"error": "unauthorized",
"reason": "You are not authorized to access this db.",
"status": 401,
"name": "unauthorized",
"message": "You are not authorized to access this db.",
"docId": "category:aktien"
}
My feeling is, that the HTTP-Connection between Pouch and Couch has a timeout... what can I do about that?
I cant find a "signal" that informs me about the timeout, so I could reconnect. Is there any?
Best Regards,
Tobias

In the settings of CouchDB you can set the session timeout... default is 10 minutes (600 s).

Related

I get Bad Request every time i try to create an azure function

I'm still new in Azure.
Today, I try to create an azure function instance
but, everytime I try to create one I get a Bad Request Error
{
"status": "Failed",
"error": {
"code": "BadRequest",
"message": "Cannot update the site '{project-name}' because it uses x64 worker process which is not allowed in the target compute mode.",
"details": [
{
"message": "Cannot update the site '{project-name}' because it uses x64 worker process which is not allowed in the target compute mode."
},
{
"code": "BadRequest"
},
{}
]
}
}
I have no idea what it does mean. So, can you give me an Idea what's wrong? and How I supposed to do to fix it?.
The Free/Shared tiers only support 32-bit application architecture. You'll need Basic or higher to use 64-bit.

Bot Framework: httpStatusCode": 504 getting Failed to send activity: bot timed out

Occasionally the bot sends a timeout error. It seems that it happens by requests with larger amout of data. Is it possible to increase the timeout or cash buffer?
Request
https://directline.botframework.com/v3/directline/conversations/xxx/activities
Response
{
"error": {
"code": "BotError",
"message": "Failed to send activity: bot timed out"
},
"httpStatusCode": 504
}
Payload
17. x-ms-bot-agent:
DirectLine/3.0 (directlinejs; WebChat/4.9.0 (Full))
18. x-requested-with:
XMLHttpRequest
4. Request Payloadview source
1. {,…}
1. channelData: {clientActivityID: "", clientTimestamp: "2020-06-05T06:57:43.001Z"}
2. channelId: "webchat"
3. from: {id: "",…}
4. locale: "en-US"
5. text: "nohy"
6. textFormat: "plain"
7. timestamp: "2020-06-05T06:57:43.045Z"
8. type: "message"
Any idea guys?
You cannot increase the timeout limit. This is a limit imposed by the Direct Line service, and is set in place for performance and stability reasons. The timeout happens because your bot/code takes too long to respond back to the service, not because of how much data (unless that large data is contributing to the length of time to reply).
You should investigate your bot and those portions of it that take longer, to see if you can decrease the time taken. If you know that there are areas (say external calls to other services, etc) that will take a long time and is unavoidable; then you should implement proactive messaging to remedy that.
https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-proactive-message?view=azure-bot-service-4.0&tabs=csharp
https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/16.proactive-messages

Logic Apps "Get file Content" Sharepoint connector timed out for files over 20MB

As the topic implies, my logic app having a Get File Content from a sharepoint connector,which was working fine for all the files less than 20 MB. For the files greater than 20 MB getting timeout after 4 retries by giving the 500 Internal Server Error
I couldn't able to find this type of size limitations in the documentations.
I tried to use the chunks options but its only for upload not for retrieve
Some Other findings :
A file with 17 MB got succeeded at the second retry, however for files more than 20 MB it always getting failed even after 4 retries.
RAW Output:
{
"error": {
"code": 500,
"source": "logic-apis-northeurope.azure-apim.net",
"clientRequestId": "3a0bf64d-2b82-4aef-92ba-ff8b101e44bb",
"message": "BadGateway",
"innerError": {
"status": 500,
"message": "Request timed out. Try again later.\r\nclientRequestId: 3a0bf64d-2b82-4aef-92ba-ff8b101e44bb\r\nserviceRequestId: e0ce569f-96aa-d08b-1c7e-20a6ccf358c3",
"source": "https://xxxxx",
"errors": []
}
}
}
P.S I'm using on-prem sharepoint, i.e gateway is already using. However no timeout logs in the gateway,which makes me to eliminate the issue is not from gateway and from logic app
We can see logic app supports get data from sharepoint according to the on-premises data gateway in this document.
Then click limits on their payload size, we can see the limits of it.
Although the document above doesn't mention the limit of 20 MB for the data response, but I think when you request the data of 17 MB, it beyond exceed the limit. So it got succeeded at the second retry but not success at the first time.

"500 Backend Error" using Gmail API - safe to retry?

I'm sending messages via the Gmail API. In particular, I am trying to send 5-7 emails from the same account to different users (1 each) within about 2 seconds.
About 8% of those emails are failing with this error:
&googleapi.Error{
Code:500,
Message:"Backend Error", Body:`{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "Backend Error"
}
],
"code": 500,
"message": "Backend Error"
}
}`,
Header:http.Header(nil),
Errors:[]googleapi.ErrorItem{
googleapi.ErrorItem{Reason:"backendError", Message:"Backend Error"}
}
}
It doesn't seem like it's specific to a particular account, as 6/7 emails may succeed.
I'm hesitant to retry this for fear of sending 2 emails to the same person.
Is there any way to tell whether this message is safe to retry?
"code": 500, "message": "Backend Error"
Is basically an issue with Google server. Either the request you are making took to long or the server preforming the request is busy and the request again took to long. It doesn't sound like what you are doing should be causing the problem.
Tips when not to run: Don't run on the hour you will be completing with everyone who has cron jobs set up also don't run at midnight (PDT) as this is when quotas reset and again you will be completing with everyone who blew out yesterdays quota.
Solution:
The normal solution is to wait a few seconds then send the same request again. (Implementing Exponential Backoff)
The flow for implementing simple exponential backoff is as follows.
Make a request to the API
Receive an error response that has a retry-able error code
Wait 1s + random_number_milliseconds seconds
Retry request
Receive an error response that has a retry-able error code
Wait 2s + random_number_milliseconds seconds
Retry request
Receive an error response that has a retry-able error code
Wait 4s + random_number_milliseconds seconds
Retry request
Receive an error response that has a retry-able error code
Wait 8s + random_number_milliseconds seconds
Retry request
Receive an error response that has a retry-able error code
Wait 16s + random_number_milliseconds seconds
Retry request
If you still get an error, stop and log the error.
Sometimes it can happen before send and sometimes after send.
I logged the "To" and "From" from five different email attempts that all received a 500 Backend Error. None of these attempts made it to the "Sent" folder of my inbox. I conclude that they were never sent, and it's safe to retry these messages. However, other people in the comments (see below) indicated that the messages actually made it to the remote mailbox, and it's not safe to retry.

Problems with pulling OneDrive/SharePoint Permissions

I am currently writing a script in nodejs to pull all DriveItems from the MS Graph API, the idea is to grab the permissions of each DriveItem so that a record can be kept and presented to the user. Our authentication with Graph is app based.
I am running asynchronous requests to MS graph which obviously results in a lot of simultaneous requests. After a few seconds of executing the script, MS graph starts returning the following errors from the endpoint and doesn't seem to recover. The status codes are a 500 internal server error, 504 gateway timeout, and 404 not found.
The number of errors returned isn't always the same; one request returns 856 failed requests, another returns 900.
Here are the different responses received from endpoints which represent true drives and driveitems:
Endpoint: https://graph.microsoft.com/v1.0/drives/(drive_id)/items/(driveitem_id)/permissions
500 Internal server error:
{
"error": {
"code": "-2146232060, Microsoft.SharePoint.SPException",
"message": "Exception from HRESULT: 0x80131904",
"innerError": {
"request-id": "794863b8-bbf1-4866-9604-f8fcec4afabe",
"date": "2016-11-18T05:41:35"
}
}
}
504 Gateway timeout:
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"request-id": "e91c3037-10b6-4523-88d3-7fc31107b719",
"date": "2016-11-18T05:46:21"
}
}
}
404 Not found error:
{
"error": {
"code": "itemNotFound",
"message": "The resource could not be found.",
"innerError": {
"request-id": "b9a8286d-ce8c-4353-b8f0-818fe0f609ea",
"date": "2016-11-18T05:41:35"
}
}
}
This errors occur for a period of time and then everything seems to work fine again.
I can confirm that these endpoints work fine when I use postman to get an individual endpoint and the same token as the script - it returns valid data. Also if I make the script synchronous, it works fine but this is not an acceptable solution as it is far too slow to process the thousands of files I am dealing with.
The only thing I can think of that would be a problem is the sheer amount of simultaneous requests happening? However I am not receiving a 429 too many requests error back from msgraph before this starts to happen.
Any help is greatly appreciated.

Resources