推送通知:ASP.NET 在无限循环中等待事件发生
我正在为 Android 构建一个推送通知系统。
我有一个 ASP.NET Web 应用程序,托管在商业托管提供商上。我有一个页面几乎总是处于无限循环中等待事件发生。
一台主机(Android 设备)加载此页面,并保持持久连接,直到该事件发生。当它发生时,它为它服务,然后回去等待它再次发生。
现在,我的问题是,此页面是否处于永久循环中,并且始终连接到客户端,是否会影响 Web 应用程序其余部分的性能?
(我认为不应该,因为服务器无论如何都会处理客户端连接的负载。我的假设是否正确?)
我应该将其部署在服务器上的不同应用程序池上吗? 另外,是否有更好的方法使用持久连接来执行推送通知?
提前致谢...
I am building a Push notification system, for Android.
I have an ASP.NET web application, hosted on a commercial hosting provider. I have one page that almost always is in an infinite loop waiting for an event to occur.
One host (Android device) loads this page, and remains connected on a persistent connection, till that event occurs. When it occurs, it serves it, and goes back to waiting for it to occur again.
Now, my question is, Is this page being in a perpetual loop, and always connected to a client going to affect the performance of the rest of the web application?
(I think it should not, because servers handle loads of client connections anyway. Am I correct in assuming this?)
Should I deploy this on a different application pool on the server?
Also, is there a better way of doing Push notifications, using persistent connections?
Thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据你的描述,你会遇到问题。首先,页面永远循环会导致超时错误(连接超时默认为 120 秒)。顺便说一句,这将导致应用程序池根据其发生的速度而失败/关闭(我不小心这样做了,相信我,这不好)。
如果您不需要 100% 实时通知,我会使用轮询设置(让他们每几分钟访问您的页面一次)。如果您确实需要 100% 实时通知,并且您的目标是 2.2 以上,请使用 云到设备消息传递。否则,您最好的选择是创建一个服务器应用程序,而不是采用 ASP.Net 方法。
Based on your description, you're going to run into issues. First, having a page that loops forever is going to cause timeout errors (connection timeout defaults to something like 120 seconds). Which, by the way, will cause the app pool to fail/shut down based on how fast it happens (I've accidentally done this, trust me it's not good).
If you don't have to have 100% real time notifications, I'd use a polling setup (let them hit your page once every couple of minutes). If you do have to have 100% real time notifications, and you're targeting 2.2 on up, use Cloud to Device Messaging. Otherwise you're best option will be to create a server application and not going the ASP.Net approach.