Lengthy HTTP calls failing in TaskPane apps on Office for Mac Client

守給你的承諾、 提交于 2019-12-24 06:34:28

问题


We have built an Excel Task Pane add-in that interacts with our server to get data from an external source. For few calls the server takes more than a minute to respond. For such calls, Excel add-in (which runs in Mac Desktop Excel 2016) doesn't receive any response (either success or failure or timeout) even though the server has sent it.

Note: This happens only when the add-in runs in Mac Desktop Excel. In other systems and browsers it works fine.

Does the Office for Mac client have a low timeout threshold? If so, is there a way to increase it? Is there any other workaround for this?


回答1:


The WebKit control that we use to host the add-in does not provide a way for us to override the default timeout for web requests. The default timeout is 60 seconds on Mac. If you need to have a request longer than 60 seconds I have verified that WebKit respects the XMLHttpRequest's timeout property on OSX 10.11.5. This request will not timeout for 120 seconds:

var xhr = new XMLHttpRequest();
var startDate = new Date();
xhr.open('GET', url, true);

xhr.timeout = 120000; // time in milliseconds

xhr.onload = function () {
  console.log((new Date() - startDate) + " milliseconds to return.");
};

xhr.ontimeout = function (e) {
  console.error("error");
};

xhr.send(null);

Note that this is not working starting in mac OS Sierra 10.12.1. There seems to have been a regression in WebKit. A tracking bug is opened here: https://bugs.webkit.org/show_bug.cgi?id=163814.



来源:https://stackoverflow.com/questions/39617221/lengthy-http-calls-failing-in-taskpane-apps-on-office-for-mac-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!