簡體   English   中英

Dialogflow Webhook(Webhook調用失敗。錯誤:500內部服務器錯誤)

[英]Dialogflow Webhook (Webhook call failed. Error: 500 Internal Server Error)

我已按照本教程的代碼( https://dialogflow.com/docs/getting-started/basic-fulfillment-conversation )將API的結果返回到對話流。 但是我的webhook一直失敗。 有人可以幫我找出原因嗎?

這是失敗的對話之一: 在此處輸入圖片說明

這是我的代碼:

'use strict';

const http = require('http');

exports.Hadoop = (req, res) => {
    // Get name node server from the request
    let nameNodeServer = req.body.queryResult.parameters['nameNodeServer']; // nameNodeServer is a required param

    // Call the Hadoop API
    getNameNodeInfo(nameNodeServer).then(function(output) {
        res.json({ 'fulfillmentText': output }); // Return the results to Dialogflow
    }).catch(() => {
        res.json({ 'fulfillmentText': 'getNameNodeInfo() Error'- });
    });
};

function getNameNodeInfo (nameNodeServer) {
    return new Promise((resolve, reject) => {
        // Create url for the HTTP request to get the name node info
        let url = 'http://' + nameNodeServer + '[rest of url]';

        // Make the HTTP request to get the name node info
        http.get(url, (res) => {
            let body = ''; // var to store the response chunks
            res.on('data', (chunk) => {body += chunk; });
            res.on('end', () => {
                // After all the data has been received, parse the JSON for desired data
                let response = JSON.parse(body);
                let beans = response['beans'][0];

                // Create response
                let output = `Percent Used: ${beans['PercentUsed']}`;

                // Resolve the promise with the output text
                console.log(output);
                resolve(output);
            });
            res.on('error', (error) => {
                console.log(`Error calling the Hadoop API: ${error}`);
                reject();
            });
        });
    });
}

我相信getNameNodeInfo函數和名稱節點服務器的檢索是正確的,因為它們在調試中記錄了正確的輸出。

診斷信息: 在此處輸入圖片說明

在此處輸入圖片說明

在此處輸入圖片說明

在此處輸入圖片說明

我在Dialogflow與某人聯系,這是他們的回應。

感謝您提供所有信息。 我在您的代碼中觀察到您使用的是http請求而不是https。 該服務必須使用HTTPS,並且URL必須是可公開訪問的,以便履行該功能。 Dialogflow不支持自簽名SSL證書。 有關SSL設置的信息,請參閱: https : //developers.google.com/web/fundamentals/security/encrypt-in-transit/enable-https

我們遇到了一個不同但相關的問題:

運行代理時出現Internal Server Error

“status”: {
   “code”: 500,
   “errorType”: “internal_server_error”,
   “errorDetails”: “Internal Server Error”
},

此錯誤不是由我們引入的任何更改引起的。 我們正在應用的開發版本中使用該代理,一天早晨它停止工作。

我們通過創建.zip並將其還原到新代理中進行了測試。 新的代理可以正常工作,但是我們將繼續在代理上將500錯誤掛接到我們的開發應用程序中。 我們提交了一個幫助請求,並在一夜之間解決了該錯誤。 我們懷疑DialogFlow團隊必須手動重啟服務器或類似的東西。

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM