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

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

Related

Gmail API Quota Limit Exceeded When Sending Too Many Emails

I am creating email automation platform using gmail api and nodejs. It works fine unless the email list contain >100 emails.
When i try to send the emails i am getting this error
Quota exceeded for quota metric 'Queries' and limit 'Queries per minute per user' of service 'gmail.googleapis.com' for consumer 'project_number:xxxxxxxxxxxxx'.
To send the email I am using the following method
const r = await gmail.users.messages.send({
auth, // coming from google oauth client
userId: "me",
requestBody: {
raw: makeEmailBody( // function to create base64 email body with necessary headers
thread.send_to,
{
address: user.from_email,
name: user.from_name,
},
subject,
template,
thread.id
),
},
});
Information about Usage limits
Per user rate limit 250 quota units per user per second, moving average (allows short bursts).
and
Method--------------------------Quota Units
messages.send-----------------100
In other words, sending 100 emails corresponds to using 10 000 quota units, but you are only allowed to use 250 quota units per second.
This means that you need to slow down your code execution to avoid running into quota issues.
This can be done with an Exponential Backoff logarithm, as explained here.

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.

Dialog flow Web hook time out

I am creating agent using dialogflow with webhook. Facing problem in webhook timeout:
webhook_status { code: 4 message: "Webhook call failed. Error: Request
timeout." }
kindly help me to increase webhook timeout time.
There is no way you can increase Time Out for webhook. Your webhook should respond back within 5 seconds (see Limits here)

"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.

Request Timeout in cast.Api.loadMedia()

I've got my Chromecasts whitelisted and was doing some sender and receiver app development.
Ran into this strange problem of a callback returning "Request timeout" after a second or two when after a few more seconds, the media started playing on the Chromecast device.
castApi.loadMedia(currentActivityId, loadRequest, launchCallback);
The status launchCallback returned was:
cast.MediaResult {
activityId: "ao4hr3w1a1gw",
status: null,
success: false,
errorString: "Request timeout"
}
This happens sporadically, depending on how fast the video load on the Chromecast device. But the timeout (probably 1 to 2 seconds) happens so quickly that it returns a failure about half the time. Am I doing something wrong here?
When it successfully runs your media (after initial timeout error message), do you get an updated successful message via your callback?

Resources