TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

MQTT: An Implementer's Perspective

47 点作者 jstclair将近 11 年前

8 条评论

eldavido将近 11 年前
I&#x27;ve been working on a project to do building monitoring. I&#x27;m building a library in C that talks to an Akka&#x2F;Scala backend.<p>I initially chose MQTT to connect from the C library (that runs on the device) to the Akka system, via RabbitMQ&#x27;s support for MQTT.<p>As I get deeper into the implementation, I&#x27;m thinking about ripping out MQTT. I just don&#x27;t know what purpose it has. I think a better pattern is to have some kind of TCP terminator that the client&#x2F;device connects to, which then fans out into an AMQP-like messaging system. Pushing messaging away from the core, far towards the edge doesn&#x27;t seem like a good idea in environments where you really care about whether something is up&#x2F;connected, and also, the wire protocol you use from the cloud to your device can be a lot different from that which you&#x27;d use in a core&#x2F;cloud&#x2F;racked messaging system.<p>I also don&#x27;t care for MQTT&#x27;s security model.<p>All in all, I&#x27;m pretty disappointed with it as a protocol. I&#x27;d take something written in protobuf and well-documented any day over mqtt.<p>My project, in case anyone&#x27;s interested: <a href="https://github.com/prefiat/iotelemetri-feederd" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;prefiat&#x2F;iotelemetri-feederd</a>
jandrewrogers将近 11 年前
This write up is right on the mark. There are quite a few things about MQTT that seem to have the goal of supporting legacy expediency. At the same time, these dubious design elements undermine the nominal goals of the standard and in some cases flat out contradict those goals.<p>We know how to design modern, efficient, flexible wire protocols that can be driven at the rates required by M2M communication patterns. MQTT does not fit this description nor even makes an attempt to reflect best practices within its current scope.
评论 #7834243 未加载
评论 #7834097 未加载
jhallenworld将近 11 年前
He says:<p>&quot;Unfortunately, MQTT defines this assurance model only for the publish gesture and not for its own, inherent operations..&quot;<p>OK, but then says:<p>&quot;That means the client is forced to retry under any such circumstances. The specification already anticipates this with making subscriptions effectively idempotent and requiring that a subscribe command matching an existing subscription must be replaced by a new subscription and that the message flow must not be interrupted. &quot;<p>So what exactly is the problem? If the client doesn&#x27;t get the SUBACK it retries. The server has to deal with it. If the server gets a SUBSCRIBE, it has to be durable because the client might have received the previous SUBACK.<p>Why add one more turn around by acking the ack? This seems like extra complexity for no reason.<p>Also he talks about lack of flow control:<p>&quot;Not having any flow control can get fairly dicey when there is significant work to do for processing a message and there might be several different subsystems on the receiving end of the MQTT connection where the work differs.&quot;<p>But there is flow control: it&#x27;s TCP. Do not read from the TCP stack unless you can handle the message, then the flow control will work. On the other hand there is no concept of trying to multiplex multiple streams over one connection (where then you start to worry about head of line blocking). If you need this, open a different TCP connection for each stream. This is not an unreasonable design choice to make...
评论 #7837035 未加载
Bug_Labs将近 11 年前
Great write up! We found many of the same issues as you did when we tried connecting devices, so we created dweet.io.<p>We are not a substitute for MQTT, but we made dweet to help you get your things online quickly and easily so you can concentrate on making apps. Standards take forever to hash out, so we made something that can get you going really quickly.<p>Have you had a chance to look into dweet? <a href="https://dweet.io" rel="nofollow">https:&#x2F;&#x2F;dweet.io</a> is the homepage, so let me know if you have any questions.<p>Thank you again
评论 #7834027 未加载
tobinharris将近 11 年前
We selected MQTT because our mobile apps are sending frequent data packets over cell-phone data tariffs. Our thinking was that a light messaging protocol such as MQTT could mean the difference between an £100,000+ monthly data bill, or £10,000.<p>I&#x27;m no expert, but I&#x27;m finding MQTT pretty bare bones, I can see the appeal of STOMP or messaging protocols that have more support for patterns such as RPC.
outside1234将近 11 年前
I&#x27;m so glad this was published because I had essentially come to the same result and thought I was missing something given all the hype around MQTT.
rdtsc将近 11 年前
Btw there is a RabbitMQ plugin that does MQTT<p><a href="http://www.rabbitmq.com/mqtt.html" rel="nofollow">http:&#x2F;&#x2F;www.rabbitmq.com&#x2F;mqtt.html</a>
jallmann将近 11 年前
What an extremely well thought-out piece. There is a certain bias towards MQTT’s suitability for building Azure-scale services (the article says as much), but I just wanted comment on a few general points.<p>&gt; you cannot return connack (which confirms establishing or recovering a session) until all server nodes have access to a replica of this fact. The spec doesn&#x27;t say that.<p>The spec should not have to say that. If you&#x27;re building high-availability, distributed <i>brokers</i> (which MQTT makes no claims about), the semantic implications of each message should certainly be considered carefully, but a protocol specification is not a &quot;how-to&quot; guide enumerating every use-case. A brief note calling into consideration special cases may be welcome, but should not be required.<p>&gt; With a &quot;pull&quot; based model that separates establishing subscriptions and message solicitation, you can leave delivery resumption control to the client, with MQTT those two aspects are coupled.<p>This behavior is a non-issue if the clear session flag is set. If it&#x27;s not being set, the assumption is that subscription state is actively managed by the server. Leaving more work to the client is half-hearted and would complicate the protocol into something like AMQP’s. (I have thoughts about whether pull models are best suited for stateless operation, but that’s neither here nor there.)<p>Client IDs are indeed mis-named. To be fair, the 3.1.1 spec allows for server-assigned client ids. That doesn&#x27;t completely mitigate the security risk, as user credentials are allowed to be shared among endpoints. This can be “fixed” at the broker level by requiring unique credentials, depending on the use case — it likely wouldn’t work for Azure.<p>The objection to the (lack of a) payload encoding is unclear. Being payload-agnostic actually a nice feature, especially on the broker side. Crucially — and please correct me if I&#x27;m wrong — MQTT is not designed as a generic mechanism to communicate with unknown clients, vis-a-vis HTTP. Clients are assumed to have awareness of the payload structure. Metadata can be further signified via a structured topic (again, clients know the format of the topic).<p>The article calls the structured-topic approach a hack, but it is a easy, readable method to impose simple structure or namespacing, and allows for things like metadata-based routing without any special effort from the broker. Hence, the need for explicit metadata (content-type, etc) seems unnecessary.<p>Regarding flow control — unless the spec declares otherwise, the broker is free to implement specific policies regarding the number of in-flight messages. For example, Mosquitto handles ACLs out-of-band. Otherwise, you can rely on TCP buffers to limit in-flight messages, or delay a QoS response until the next message can be handled. This also applies to data management policies, e.g. state or message retention, QoS-2 allowances, and so forth. Spec ambiguity is not necessarily a bad thing here. Over-specifying could constrain other use-cases; the insistence on “watertight assurances” doesn’t always hold water.<p>Multiplexing is not really an issue, unless you are sending large payloads — although if you are, I would venture to say you’re not using the right protocol anyway. I will place fault with the protocol for allowing 256MB payloads — this really just goes to show the incongruity between MQTT’s frugality with headers and wastefulness everywhere else.<p>All this assumes the user is using MQTT as it was designed: for <i>simple</i> pub-sub. What it allows out-of-the-box may not be flexible enough for many use cases. These problems can be mostly fixed with small changes to the protocol, or fixating on certain assumptions. This usually necessitates writing&#x2F;modifying your own broker, but fortunately MQTT is simple enough that it isn’t a heroic deed. Of course, this doesn’t apply if you’re building a SaaS broker like Azure — but for any other purpose, MQTT can be viewed as a springboard.<p>Granted, all this sounds like it requires thinking too much about details that should otherwise be solved by things like AMQP. Maybe so. However, more sophisticated systems have many more knobs to tune, and the complexity rises accordingly. MQTT doesn’t have that problem out-of-the-box.