【问题标题】:Why browser get response from vibed so slowly?为什么浏览器从 vibed 得到响应如此缓慢?
【发布时间】:2016-03-22 12:21:39
【问题描述】:

我正在从浏览器向 vibed 发送数据。在振动控制台上,我立即收到请求。但在浏览器控制台中,我需要两次等待 console.log 5-8 秒。而且我不明白问题出在哪里。

     postQuestionsContent : function()
     {
        this.$http.post('http://127.0.0.1:8080/questions', JSON.stringify(this.questions)).then(function(response)
        {
           console.log("Server response: ", response.status); // 5-8 seconds here

        }, function(response)
          {
            console.log("Server report that it can't process request");
          }
        ); 
      }

还有D码:

void getQuestions(HTTPServerRequest req, HTTPServerResponse res)
{

    if (req.session)
    {   
       Json questions;
       try
       {
        questions = req.json;
        writeln("We got questions content!");
        res.statusCode = 200;
       }
       catch (Exception e)
       {
        writeln("Can't parse incoming data as JSON");
        writeln(e.msg);
        writeln("------------------------------------------");
       }
    }

    else
    {
        res.statusCode = 401;
    }

   res.writeVoidBody;
}

【问题讨论】:

  • 它与浏览器有什么关系?如果服务器响应时间过长,记录传入和传出的 HTTP 请求并找出瓶颈。
  • 您可以尝试使用 --vv 运行您的 vibe 可执行文件,以启用非常详细的日志记录以查看到底发生了什么。

标签: javascript d vue.js vibed


【解决方案1】:

您阅读过文档吗?

https://vibed.org/api/vibe.http.server/HTTPServerResponse.writeVoidBody

他们在那里说:

对于空主体,只需使用 writeBody,因为这种方法会导致一些保持活动连接的问题。

所以也许你应该尝试使用

https://vibed.org/api/vibe.http.server/HTTPServerResponse.writeBody

【讨论】:

    猜你喜欢
    • 2020-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-16
    • 1970-01-01
    • 2011-10-12
    • 2013-02-26
    • 1970-01-01
    相关资源
    最近更新 更多