简体   繁体   English

azure web 应用程序中的服务器发送事件延迟

[英]Server send events are getting delayed in azure web app

I have created server send events to send the messages from node server.我创建了服务器发送事件以从节点服务器发送消息。 Everything works fine in localhost but when I deploy it to azure web app it takes nearly 15 to 20 seconds to send the data to the client.在 localhost 中一切正常,但是当我将其部署到 azure Web 应用程序时,将数据发送到客户端需要将近 15 到 20 秒。 Do i need to configure anything in azure.我需要在 azure 中配置任何东西吗? Hope someone can help me out from this issue.希望有人可以帮助我解决这个问题。 Thanks in advance.提前致谢。

"

It could be a buffering issue.这可能是一个缓冲问题。 Depending on your browser and which polyfill you are using, messages get cached until the cache is flushed.根据您的浏览器和您使用的 polyfill,消息会被缓存,直到缓存被刷新。

Since it works locally, there may be a difference in the node version running locally and the version on the App Service (I am assuming that you are running the node app in App Service, and using the same browser to test locally and in Azure).由于是在本地运行,所以本地运行的node版本和App Service上的版本可能会有所不同(我假设你在App Service中运行node应用,并且在本地和Azure中使用相同的浏览器进行测试) .

For more details see: https://github.com/EventSource/eventsource/issues/88更多详情请参见: https : //github.com/EventSource/eventsource/issues/88

In my case it was buffering issue.就我而言,这是缓冲问题。 I did not get a response or got with huge delay.我没有得到回应或延迟很大。

I have added headers to disable cache and buffering for the response.我添加了标题以禁用响应的缓存和缓冲。

Cache-Control: no-cache;<\/code>

X-Accel-Buffering: no;<\/code>

It helped me.它帮助了我。

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM