Error: 4 DEADLINE_EXCEEDED: Deadline Exceeded - node.js

After few transaction while using Dialogflow APIs, DEADLINE_EXCEEDED: Deadline Exceeded error is coming and after that I always need to restart the service, then again it starts working for a while. Not getting any relevant answers even after trying lots of blogs.
Using node package: dialogflow
and dialogflow standard edition (Free Version)
Tried with various agent of Dialogflow, but not getting the response.
Error: 4 DEADLINE_EXCEEDED: Deadline Exceeded
at Object.exports.createStatusError (/srv/node_modules/grpc/src/common.js:87:15)
at Object.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:1188:28)
at InterceptingListener._callNext (/srv/node_modules/grpc/src/client_interceptors.js:564:42)
at InterceptingListener.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:614:8)
at callback (/srv/node_modules/grpc/src/client_interceptors.js:841:24)
code: 4,
metadata: Metadata { _internal_repr: {} },
details: 'Deadline Exceeded' }
While using dialogflow node package, and here using
const sessionClient = new dialogflow.SessionsClient();
to detect intent not getting the result as detected intent after hitting query for a phrase.

The DEADLINE_EXCEEDED error is triggered when the webhook call exceeds the maximum wait time.
As stated on DialogFlow fulfillment documentation:
The response must occur within 10 seconds for Actions on Google
applications or 5 seconds for all other applications, otherwise the
request will time out.
If you want, on dialogflow, you can set a pre-defined message that is sent when the fulfillment request exceeds the available time.

Related

POST to Bot timed out after 15s

Sometimes I am getting timeout error from my bot. Getting timeout for the first response itself.
Is there any option to increase that 15 seconds time?
Also, is there any option to skip this timeout issue?
Exception type : Microsoft.Bot.Schema.BotTimeoutException
Failed method : Microsoft.Bot.ChannelConnector.BotAPI+d__31.MoveNext
It is bot using C# and directlinechannel.
Please let me know if you need any other information
This is a problem in the Bot Framework, the direct line connection will timeout in 15s and currently there is no way to suppress it, check the following thread.
https://github.com/microsoft/botframework-sdk/issues/3220
this type of enforcement to make the bot more active and force to make faster bots.
same goes for Google's Dialog flow which timeouts at 5 seconds and Alexa Skill which timeouts at 8 seconds, so 15 second for Bot Framework is generous :P
You need to handle this with Periodic refresh token
var credentials = new MicrosoftAppCredentials(appID, appPassword);
Task.Factory.StartNew(async () =>
{
while (!_getTokenAsyncCancellation.IsCancellationRequested)
{
try{
var token = await credentials.GetTokenAsync().ConfigureAwait(false);
}
catch(MicrosoftAppCredentials.OAuthException ex)
{
Trace.TraceError(ex.message);
}
await Task.Delay(TimeSpan.FromMinutes(30), _getTokenAsyncCancellation.Token).ConfigureAwait(false);
}
}).ConfigureAwait(false);

Error: Request unsafe for browser client domain: dialogflow.googleapis.com

I'm setting up a DialogFlow wrapper and I'm using the DialogFlow JavaScript SDK. But, I'm getting the following error:
Error: Request unsafe for browser client domain:
dialogflow.googleapis.com
This was working before, but I'm not sure why it suddenly stopped working.
I've tried reverting all code to a version that worked. I'm sure it's a DialogFlow error.
const intentDetectResponse = await sessionClient.detectIntent(request)
The complete error log is as follows:
{ Error: Request unsafe for browser client domain: dialogflow.googleapis.com
at Http2CallStream.call.on (/Users/NewProject/node_modules/#grpc/grpc-js/build/src/client.js:101:45)
at Http2CallStream.emit (events.js:194:15)
at process.nextTick (/Users/NewProject/node_modules/#grpc/grpc-js/build/src/call-stream.js:71:22)
at process.internalTickCallback (internal/process/next_tick.js:70:11)
code: 3,
details:
'Request unsafe for browser client domain: dialogflow.googleapis.com',
metadata:
Metadata {
options: undefined,
internalRepr: Map { 'grpc-server-stats-bin' => [Array] } } }
Pretty sure this is something wrong with dialogflow service. This is not the first time dialogflow facing some issues.
Pretty sure something is wrong with one of their servers behind the load balancer. If you try multiple times, sometimes a request can get through. But it should most definitely be a dialogflow api server issue.
It was issue from Dialogflow side, their technical team worked on it and resolved it. However they did not tell exactly what was the actual issue.
There is github issue as well for the same.
I think it's a rate limit of the Dialogflow API? I had the same error with a python script, after a few minutes it worked fine...
Says here there is a limit for 60 requests per minute.

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.

google spanner close connection

I running my api based on swagger and node.
When my api is running for few minutes without a request and then i send an api request to it, I got this error:
{ Error: {"created":"#1488097564.272436000","description":"Delayed close due to in-progress write","file":"../src/core/ext/transport/chttp2/transport/chttp2_transport.c","file_line":406,"grpc_status":14,"referenced_errors":[{"created":"#1488097564.272434000","description":"Endpoint read failed","file":"../src/core/ext/transport/chttp2/transport/chttp2_transport.c","file_line":1851,"occurred_during_write":1,"referenced_errors":[{"created":"#1488097564.272350000","description":"Secure read failed","file":"../src/core/lib/security/transport/secure_endpoint.c","file_line":166,"referenced_errors":[{"created":"#1488097564.272347000","description":"Socket closed","fd":24,"file":"../src/core/lib/iomgr/tcp_posix.c","file_line":249,"target_address":"ipv4:172.217.19.10:443"}]}]}]}
at ClientReadableStream._emitStatusIfDone (/Users/aronsuarez/Code/asate/admin-apis/wiki-admin-api/node_modules/grpc/src/node/src/client.js:201:19)
at ClientReadableStream._readsDone (/Users/aronsuarez/Code/asate/admin-apis/wiki-admin-api/node_modules/grpc/src/node/src/client.js:169:8)
at readCallback (/Users/aronsuarez/Code/asate/admin-apis/wiki-admin-api/node_modules/grpc/src/node/src/client.js:242:12) code: 14, metadata: Metadata { _internal_repr: {} } }
I think google spanner is closing the connection, why and how can prevent it from to that?
The only way that i see in the docs is to send periodically a SELECT 1 request to spanner.
Is this correct?
Thanks for help

Resources