Node.js 502(坏网关)在向bot发送帖子时

Node.js 502(坏网关)在向bot发送帖子时,node.js,botframework,direct-line-botframework,Node.js,Botframework,Direct Line Botframework,我正在构建一个非常简单的交互式BOT,只使用HTTP-GET和普通JS。 有时我让机器人做时间密集型处理,需要40秒才能回复。在这种情况下,我得到了以下回复 那么,这是预期的回报吗 我做了什么改变,以便得到一个有意义的反应,而不认为这种情况是一个真正的错误? 对于这种情况还有其他建议吗 谢谢大家! 502 (Bad Gateway) { "error": { "code": "ServiceError", "message": "Failed to send activity

我正在构建一个非常简单的交互式BOT,只使用HTTP-GET和普通JS。 有时我让机器人做时间密集型处理,需要40秒才能回复。在这种情况下,我得到了以下回复

  • 那么,这是预期的回报吗

  • 我做了什么改变,以便得到一个有意义的反应,而不认为这种情况是一个真正的错误?

  • 对于这种情况还有其他建议吗

  • 谢谢大家!

    502 (Bad Gateway)
    {
      "error": {
        "code": "ServiceError",
        "message": "Failed to send activity: bot returned an error"
      }
    }
    
    后请求

    //send token and message
    function sendMessage() {
      var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
    
    
        if (this.readyState == 4 && this.status == 200) {
    
          var responseObj = JSON.parse(this.responseText);
          convMsgID =responseObj.id;
          latestUserMessage = document.getElementById('textToSend').value;
          showUserMessage();
          document.getElementById('textToSend').value = "";
          getReply();
        }
        else{
          console.log("error :"+ this.responseText);
        }
    
      };
      var postUrl = "https://directline.botframework.com/v3/directline/conversations/" + convID + "/activities";
      xhttp.open("POST", postUrl, true);
    
      var authToken="Bearer " + convToken;
      xhttp.setRequestHeader("Authorization", authToken);
      xhttp.setRequestHeader("Content-Type", "application/json");
    
    
    
      var messageBody = '{"type": "message","from": {"id": "user1"},"text": "';
          messageBody =  messageBody + document.getElementById("textToSend").value;
          messageBody = messageBody + '"}';
    
      console.log("messageBody"+ messageBody);
      xhttp.send(messageBody);
      document.getElementById("send-icon").src="./send.png";
    
    }
    
    获取请求

        function getReply() {
      var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
    
    
    
        if (this.readyState == 4 && this.status == 200) {
    
          var responseObj = JSON.parse(this.responseText);
          console.log("length" + (responseObj.activities.length -1));
          console.log("response :"+ responseObj.activities[responseObj.activities.length -1].text);
          latestBotMessage = responseObj.activities[responseObj.activities.length - 1].text
    
    
          showBotMessage();
        }
        else{
            console.log("response"+ this.responseText);
        }
    
      };
      var postUrl = "https://directline.botframework.com/v3/directline/conversations/" + convID + "/activities";
    
      xhttp.open("GET", postUrl, true);
    
      var authToken="Bearer " + convToken;
      xhttp.setRequestHeader("Authorization", authToken);
     xhttp.send();
    
    }
    
    1) 是的,如果bot回复时间超过15秒,则需要502

    2和3)在启动长时间运行的流程之前,对用户做出响应。让某个工人作业执行长操作(Azure功能?),完成后,将结果作为主动消息发送给用户:

    1)是的,如果bot回复时间超过15秒,则需要502

    2和3)在启动长时间运行的流程之前,对用户做出响应。让一些工人作业执行长操作(Azure功能?),完成后,将结果作为主动消息发送给用户: