如何使用 ASP.Net、IISNode、Node.JS 和 SQL Server 实现 Socket.IO 以实现基于事件的推送通知? [英] How to implement Socket.IO with ASP.Net, IISNode, Node.JS, and SQL Server for event-based push notifications?

查看:24
本文介绍了如何使用 ASP.Net、IISNode、Node.JS 和 SQL Server 实现 Socket.IO 以实现基于事件的推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一个通知项目,想要推送事件通知.这些是诸如登录、个人资料更改等内容,并将显示给适当的客户端.我想讨论一些将它们组合在一起的想法,并就最佳方法获得一些建议.

For a notification project, would like to push event notifications out. These are things like login, change in profile, etc., and to be displayed to the appropriate client. I would like to discuss some ideas on putting it together, and get some advice on the best approach.

我注意到这里CouchDB 可以通过 _changes 流检测到,由 Node 获取,然后启动一个进程.我想实现这样的东西(我使用的是 SQL Server,但这个级别的入口点可能不是最好的解决方案).

I noticed here that changes made to a CouchDB can be detected with a _changes stream, picked up by Node, and a process kicks off. I would like to implement something like this (I'm using SQL Server, but an entry point at this level may not be the best solution).

我没有遵循 CouchDB 示例(检测基于数据库的事件,我认为这只会使事情复杂化,因为我们对客户端事件感兴趣),我认为当事件发生时,例如用户登录,然后消息与一些事件细节(RESTful 请求?)一起发送到节点服务器.然后处理此消息并将其广播给所有连接的客户端;相应的客户端显示通知.

Instead of following the CouchDB example (detecting database-based events, I think this just complicates things, since we're interested in client events), I was thinking that when an event occurs, such as a user login, then a message is sent to the Node server with some event details (RESTful request?). This message is then processed and broadcast to all connected clients; the appropriate client displays notification.

提议的生态系统:

  • .Net 4.0
  • IIS
  • IISNode
  • Socket.IO
  • Node.JS
  • SQL Server 2008

这将建立在使用 .Net 框架(IIS 等)的现有项目之上.许多客户端的浏览器不支持 Web 套接字,因此使用 Socket.IO 是一个不错的选择(后备支持).但是,从我可以看到,Socket.IO only 仍然只支持通过 IISNode 进行长轮询(这不是真正的问题).

This will be built on top of an existing project using the .Net framework (IIS, etc.). Many of the clients' browsers do not support web sockets, so using Socket.IO is a good option (fallback support). However, from what I can see, Socket.IO only still only supports long polling through IISNode (which isn't really a problem).

一个选项是将 Socket.IO/Node 端点公开给所有客户端,以便基于客户端的通知可以通过 JS 发送到节点服务器,节点服务器会广播消息.(遵循基本的聊天服务器/client/server 示例).

An option would be to expose the Socket.IO/Node endpoint to all clients, so that client-based notifications can be sent through JS to the Node server, which broadcasts the message. (follows the basic chat-server /client/server examples).

或者,可以使用 IIS 端点,但只能支持长轮询(通过 Socket.IO).这将提供一些额外的 .Net 后端处理,但可能会使架构过于复杂.

Alternately, an IIS endpoint could be used, but could only support long polling (through Socket.IO). This would offer some additional .Net back-end processing, but may be over-complicating the architecture.

是否有适用于 Node 的基于 SQL Server 的事件通知?

Is there SQL Server-based event notification available for Node?

最好的方法是什么?

如果我没有正确理解术语生态系统配置,请澄清.

If I didn't get the terminology ecosystem configuration right, please clarify.

谢谢.

推荐答案

我建议您查看 SignalR 在考虑将 iisnode/node.js 添加到现有 ASP.NET 应用程序的技术组合之前.

I would recommend you check out SignalR first before considering adding iisnode/node.js to the mix of technologies of your pre-existing ASP.NET application.

关于 websockets,无论你使用 ASP.NET 还是 node.js (socket.io),你只能使用 HTTP 长轮询来获得低延迟通知,因为在 Windows 8 之前 HTTP.SYS/IIS 不支持 websockets.iisnode 当前不支持 websockets(即使在 Windows 8 上),但可以稍后添加此类支持.

Regarding websockets, regardless if you use ASP.NET or node.js (socket.io), you can only use HTTP long polling for low latency notifications, as websockets are not supported by HTTP.SYS/IIS until Windows 8. iisnode does not currently support websockets (even on Windows 8), but such support could be added later.

我最近做了一些关于从 node.js 访问 MSSQL 的研究.有一些 OSS 项目,其中一些使用本机的、特定于平台的扩展,一些尝试纯粹在 JavaScript 中实现 TDS 协议.我不知道有什么可以让您访问 SQL 通知功能.然而,MSSQL 团队本身正在为 node.js 投资一流的 MSSQL 驱动程序,因此这是值得关注的事情(https://github.com/tjanczuk/iisnode/issues/139).

I did some research lately regarding MSSQL access from node.js. There are a few OSS projects out there, some of them use native, platform-specific extensions, some attempt implementing TDS protocol purely in JavaScript. I am not aware of any that would enable you to access the SQL Notifications functionality. However, the MSSQL team itself is investing in a first class MSSQL driver for node.js, so this is something to keep an eye on going forward (https://github.com/tjanczuk/iisnode/issues/139).

如果您打算使用 SQL 通知来支持低延迟通知,我强烈建议您从模拟 SQL 服务器级别所需流量级别的性能基准测试开始.SQL 通知主要是作为一种机制来帮助在内存缓存中保持与数据库内容一致,因此它可能满足也可能不满足通知场景的要求.至少,这些测量将帮助您开始更好的设计.

If you plan to use SQL Notifications to support low latency notifications, I would strongly recommend starting with performance benchmarks that simulate the desired level of traffic at the SQL server level. SQL Notifications were meant primarily as a mechanism to help maintain in memory cache consistent with the content of the database, so it may or may not meet the requirements of your notification scenario. At the very minimum these measurements would help you start with a better design.

这篇关于如何使用 ASP.Net、IISNode、Node.JS 和 SQL Server 实现 Socket.IO 以实现基于事件的推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆