用于订阅/发布 MQTT (Really Small Message Broker) 的 C#

时间:2022-12-03
本文介绍了用于订阅/发布 MQTT (Really Small Message Broker) 的 C# 客户端库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为 Android 实现推送通知,但将无法访问 Internet,并且只能访问 Intranet.所以我想我不能使用 C2DM 和第三方 API,比如 UrbanAirship.所以我正在考虑使用 MQTT RSMB(真正的小型消息代理)、C# .net 作为代理的发布者和 Android 的 wMqtt.jar 作为代理的订阅者.

我已经下载了 RSMB 并找到了以下 exe:-broker.exe-stdinpub.exe-stdoutsub.exe

我已成功从 Android 订阅并使用带有主题的 stdinpub.exe 发布消息.

我想从你们那里得到一些关于以下方面的建议:

1). RSMB 是免费的吗?还有其他适合我的选择吗?

2).我将如何使用 C#(用于发布和订阅)连接到 RSMB 代理.是否有任何用于 RSMB 的 C# 客户端库?

3).MQTT的性能和可靠性如何?我可能需要同时推送数百条消息.

4).如果没有其他方法,那么我正在考虑在我的 C# 应用程序中执行 stdinpub.exe.(这可能听起来很糟糕).

我发现网络上关于 MQTT 的信息很少,我真的应该这样做还是有其他选择?

解决方案

好的,这里有一个细目:

1) 您需要阅读下载 RSMB 时附带的许可证文件.我的理解是您不能将 RSMB 用于商业目的,如果 IBM 将其作为商业产品发布,您必须停止使用它.

有一个名为 Mosquitto(我开发的)的开源 MQTT 代理可用.它提供完整的 MQTT 协议支持,可用于多种平台.它还包括 C 语言的客户端库,带有 C++ 和 Python 包装器,以及示例发布和订阅客户端.您可以在 http://mosquitto.org/

获得更多信息

2) 有两个 C# 库可用,尽管我自己从未使用过它们.您可以在 http://mqtt.org/software>

3) 我让 RSMB 和 Mosquitto 在一台旧的 VIA C3 600MHz 机器上每秒处理 1500 条消息(每条 100 字节).在更现代的硬件上,我希望它们的性能明显更好.

关于MQTT的信息,希望mosquitto网站上有合理的数量——见http://例如,mosquitto.org/man/mqtt-7.html 概述.您也可以在 http://webchat.freenode.net/ 的 Freenode 网络上的 #mqtt irc 频道上提问.还有一个位于 https://launchpad.net/~mqtt-users 的邮件列表,可能有用.

恐怕我无法真正评论您是否应该使用 MQTT 或其他东西.

I need to implement the push notification for Android but there will not be internet access and only intranet access is available. So I think I cannot use C2DM and third party API like UrbanAirship. So I am thinking of using MQTT RSMB(Really Small Message Broker), C# .net as Publisher to the broker and wMqtt.jar for Android as subcriber to the broker.

I have downloaded the RSMB and found the followings exe: -broker.exe -stdinpub.exe -stdoutsub.exe

I have successfully subscribed from Android and published messages using stdinpub.exe with topic.

I would like to get some advice from you guys on the followings :

1).Is RSMB free? Is there any other alternatives that suit my case?

2).how will I be able to connect to the RSMB broker using C# (for publishing and subscribing). Are there any C# client library for RSMB?

3).How is the performance and reliability of the MQTT ? I might need to push a few hundreds of messages at the same time.

4).If there is no other ways then I am thinking of executing the stdinpub.exe inside my C# application.(It might sound bad).

I find that there is very little information about MQTT on the web and should I really go that way or are there any other alternatives?

解决方案

Ok, here's a breakdown for you:

1) You need to read the license file that was included with RSMB when you downloaded it. My understanding is that you can't use RSMB for commercial purposes and if IBM release it as a commercial product you have to stop using it.

There is an open source MQTT broker available called Mosquitto (which I develop). It provides full MQTT protocol support and is available for a number of platforms. It also includes client libraries in C, with C++ and Python wrappers, as well as example publish and subscribe clients. You can get more information at http://mosquitto.org/

2) There are two C# libraries available, although I've never used either of them myself. You can find a link to them as well as a whole load of other MQTT related software at http://mqtt.org/software

3) I've had RSMB and Mosquitto handling 1500 messages (100 bytes each) per second on an old VIA C3 600MHz machine. On more modern hardware I'd expect them to perform significantly better.

With regards to information on MQTT, I hope that there is a reasonable amount on the mosquitto website - see http://mosquitto.org/man/mqtt-7.html for an overview for example. You can also come ask questions on the #mqtt irc channel on the Freenode network at http://webchat.freenode.net/ There is also a mailing list at https://launchpad.net/~mqtt-users which may be of use.

I'm afraid I can't really comment on whether you should be using MQTT or something else.

这篇关于用于订阅/发布 MQTT (Really Small Message Broker) 的 C# 客户端库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:OneSignal 推送通知 ClickEvent 显示空值 Windows phone 下一篇:寻找新电子邮件的实时 IMAP 通知

相关文章

最新文章