SignalR icon indicating copy to clipboard operation
SignalR copied to clipboard

Are there any plans to support MQTT Protocol?

Open milenstack opened this issue 9 years ago • 34 comments

RT:Are there any plans to add MQTT Protocol?

milenstack avatar Jun 18 '17 16:06 milenstack

I have a prototype of it but it's not on the top of the priorities list right now. Are you looking for a service side programming model for MQTT? Are you looking for a way to use Hubs as MQTT? That would help us understand what the intended usage is.

davidfowl avatar Jun 18 '17 16:06 davidfowl

Use in IoT devices, which is the advantage of MQTT

milenstack avatar Jun 18 '17 16:06 milenstack

@gujunxiong I get that, I'm asking what exactly you are looking for. What sorta code do you want to write on both the client and the server?

davidfowl avatar Jun 18 '17 16:06 davidfowl

Client:

  1. Communication using the class library of the MQTT standard protocol
  2. Through SIGNALR Client Agent to MQTT server Server:
  3. Handling the message event, authentication, agent to MQTT server;
  4. is itself a MQTT server

Sorry, my English is very bad. --from Microsoft translation

milenstack avatar Jun 18 '17 16:06 milenstack

RPC over MQTT doesn't seem like a great fit so I'm not sure if it would match SignalR semantics. We could look at what it would take regardless to see if it makes sense.

davidfowl avatar Jun 18 '17 17:06 davidfowl

That will be compatible with mixed protocols. Automatically identify the content of the protocol and handle it accordingly

milenstack avatar Jun 18 '17 17:06 milenstack

I'm not sure what you mean. I'm sure it could be done but I don't know if it makes sense. The calling pattern for SignalR Hubs isn't pub/sub though I'm sure it could be made to work.

davidfowl avatar Jun 18 '17 17:06 davidfowl

Using SIGNALR client or MQTT client, send message to SIGNALR server, If SIGNALR server is not MQTT server, you can let it do proxy services to MQTT server, So Signalr Clinet and MQTT client can receive messages at the same time.

milenstack avatar Jun 18 '17 17:06 milenstack

Supports both IoT and web,A service, multi - platform compatible

milenstack avatar Jun 18 '17 17:06 milenstack

@gujunxiong if you'd like to contribute that would be great. Here's the hub protocol https://github.com/aspnet/SignalR/blob/dev/specs/HubProtocol.md. A good first step would be helping us figure out what it would look like using MQTT. What do each of the frames look like, and how would they be interpreted by the MQTT client and SignalR server.

davidfowl avatar Jun 18 '17 17:06 davidfowl

Some inspiration http://docs.gadgetkeeper.com/display/docs/JSON-RPC+over+MQTT

davidfowl avatar Jun 18 '17 17:06 davidfowl

Mainly according to the protocol header for processing adaptation, through the server middleware to identify the protocol forwarded to the Hub. Unfortunately, I don't have the ability to do this right now.

milenstack avatar Jun 18 '17 17:06 milenstack

No problem. Helping us brainstorm would be good enough. I don't think it needs to be a separate middleware but we'd need to figure out what messages would look like. Maybe it's just PUBLISH both ways with a JSON/Binary payload saying which hub to invoke. SUBSCRIBE doesn't seem to make much sense.

http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html

davidfowl avatar Jun 18 '17 17:06 davidfowl

Subscription is still necessary, after all, this is an advantage on the IoT, just request the message on demand. SIGNALR already supports HTTP, WebSocket, and if it supports MQTT, it's a very powerful service.

milenstack avatar Jun 18 '17 17:06 milenstack

look here, Using WebSocket as a network transport http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718127

milenstack avatar Jun 18 '17 17:06 milenstack

What would you be subscribing to? Specific client method callbacks? The hub itself?

MQTT and websockets aren't in the same category. Mqtt is framing on top of a steam of bytes. You can do mqtt on top of web sockets so bringing that up kinda confuses the discussion.

So here's a strawman:

  • mqtt Client subscribes to a specific hub
  • method invocations are handled by bidirectional Publish (same for results?)

davidfowl avatar Jun 18 '17 17:06 davidfowl

In fact, we can use the Android message to do a case, based on MQTT implementation or SIGNALR implementation, they ultimately want to get the result is only the content of the message, as well as the specific protocol header. It is not possible to use Google's messaging service in China (China Network firewall GFW), so it is based on pub, or duplex protocol.

milenstack avatar Jun 18 '17 18:06 milenstack

At a later time, we should look into writing a sample showing this.

muratg avatar Jun 23 '17 21:06 muratg

@davidfowl You subscribe to topics (more on this here: http://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices and https://mosquitto.org/man/mqtt-7.html or http://www.ev3dev.org/docs/tutorials/sending-and-receiving-messages-with-mqtt/)

This might be similar to callbacks that are currently in SignalR, but MQTT has ability to subscribe using special characters '#' or '+'.

Ideally using SignalR we could create hubs that would allow us to use MQTT to build IOT solutions.

So for example when we create a hub called GreenhouseHub with method Temperature You could publish to it using greenhouse/temperature and also You could subscribe to that topic using same path.

As @milenstack mentioned this would be nice addition, especially for IOT.

Misiu avatar Jun 26 '17 14:06 Misiu

There's no disagreement that "it would be nice", it just needs to be designed.

davidfowl avatar Jun 26 '17 14:06 davidfowl