'Error: Total timeout of API google.cloud.dialogflow.v2.Sessions exceeded "220000" milliseconds before any response was received

today my DialogFlow API connection stopped working. When I send a request I'm always getting a timeout whatsoever in my Windows home machine it works. On my Ubuntu VPS it used to work as well but for some reason, it ain't working no more

I'm using NodeJS 16.15.0 LTS on both All packages seem to be up to date on both machines and I haven't tweaked anything it just suddenly stopped working

     * TODO(developer): UPDATE these variables before running the sample.
     */
    // projectId: ID of the GCP project where Dialogflow agent is deployed
    const projectId = "**********";
    
    const credentials_file_path = "**********";
    
    // sessionId: String representing a random number or hashed user identifier
    const sessionId = '123456';
    // queries: A set of sequential queries to be send to Dialogflow agent for Intent Detection
    // const queries = [
    //     'Hello',
    //     'How are you?'
    //     //   'Next monday at 3pm for 1 hour, please', // Tell the bot when the meeting is taking place
    //     //   'B'  // Rooms are defined on the Dialogflow agent, default options are A, B, or C
    // ]
    // languageCode: Indicates the language Dialogflow agent should use to detect intents
    const languageCode = 'es';
    
    // Imports the Dialogflow library
    const dialogflow = require('@google-cloud/dialogflow');
    
    // Instantiates a session client
    const sessionClient = new dialogflow.SessionsClient({
        keyFilename: credentials_file_path,
    });
    
    async function detectIntent(
        projectId,
        sessionId,
        query,
        contexts,
        languageCode
    ) {
        // The path to identify the agent that owns the created intent.
        const sessionPath = sessionClient.projectAgentSessionPath(
            projectId,
            sessionId
        );
    
        // The text query request.
        const request = {
            session: sessionPath,
            queryInput: {
                text: {
                    text: query,
                    languageCode: languageCode,
                },
            },
        };
    
        if (contexts && contexts.length > 0) {
            request.queryParams = {
                contexts: contexts,
            };
        }
    
        const responses = await sessionClient.detectIntent(request);
        return responses[0];
    }
    
    // export
    async function executeQuery(sessionId, query) {
        // Keeping the context across queries let's us simulate an ongoing conversation with the bot
        let context;
        let intentResponse;
        try {
            console.log(`Sending Query: ${query}`);
            intentResponse = await detectIntent(
                //ProjectID
                "**********",
                sessionId,
                query,
                context,
                //Language Code
                "**"
            );
            console.log('Detected intent');
            console.log(
                `Fulfillment Text: ${intentResponse.queryResult.fulfillmentText}`
            );
            // Use the context from this response for next queries
            context = intentResponse.queryResult.outputContexts;
            //Return text
            return intentResponse.queryResult.fulfillmentText;
        } catch (error) {
            console.log(error);
        }
    };
    module.exports = { executeQuery }
    // executeQuery("123456", "hola").then((test) => {
    //     console.log(test)
    // }
    // )

Thanks in advance! :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source