Hi Sourav,

Could you confirm whether you were able to make HAProxy work with MQTT??

Baptiste

On Fri, Sep 11, 2015 at 2:14 PM, Baptiste <[email protected]> wrote:
> Hi Sourav,
>
> Thanks a lot for the mail and the screenshot.
> That said, usually, when we ask for a capture, we mean a pcap file, not a
> png one :)
> It's fine, I have the information I need.
>
> I also used this documentation:
> http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718037
>
>
>> Please note that the MQTT messages are carried on top of TCP. Also, as
>> mentioned in previous mail, I am trying to load balance the traffic based on
>> the topic mentioned in the MQTT message( 3rd line from end ) which means
>> that all the traffic corresponding to a particular topic should be forwarded
>> to a specific server only.
>
>
> That's doable only in the following condition:
> - the client speaks first (no server banner)
> - the information is available in first session buffer
> - the information is available always at the same place
>
> It seems MQTT meet the 3 rules above, so we may be able to do something.
>
>> So considering above requirement, I have the following questions :
>>
>> 1. Is MQTT already supported as an out of box feature?
>
>
> No, MQTT is not supported out of the box.
>
>>
>> 2. Is there a configurable hook/plugin through which above can be
>> achieved?
>
>
> You might be able to code a MQTT protocol parser in Lua.
> You could even do MQTT routing to a specific farm based on the topic, but
> load-balancing is an other story.
>
>>
>> 3. If no configuration/plugins are available, how easy it would be to add
>> the feature/code in order to retrieve payload information from TCP packets
>> and parse it as par MQTT?
>
>
> Very complicated, I'm afraid...
>
>>
>> 4. What are main modules which I should look into in order to implement
>> the same in case not yet implemented?
>>
>
> Well, as I mentionned above, there might be some stuff we can do.
> Please check
> http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#req.payload_lv
>
> Following your capture, this fetch can be used to retrieve the whole topic:
> req.payload_lv(1,1) => it fetch content in the TCP payload buffer whose size
> is specified at byte 1 for 1 byte and data is stored right after the size.
>
> This fetch has the corresponding ACL to match against static patterns.
> Imagine 3 topics: topic1, topic2, topic3, then you could do:
>
> frontend mqtt
> [...]
>  use_backend bk_topic1 if { req.payload_lv(1,1),lower topic1 }
>  use_backend bk_topic2 if { req.payload_lv(1,1),lower topic2 }
>  use_backend bk_topic3 if { req.payload_lv(1,1),lower topic3 }
>
> backend bk_topic1
> [...]
>
> backend bk_topic2
> [...]
>
> backend bk_topic3
> [...]
>
> The same could be applied in a single backend, using the use-server
> statement.
>
> I hope this help and this is enough.
>
> Be aware that once the TCP session has been forwarded to a server, then all
> subsequent messages are going to be forwarded to this server, regardless of
> the next topics set over the same connection.
> To be routed again, a client must send next PUBLISH message over a new TCP
> connection.
>
> Baptiste
>
>
>
> On Thu, Sep 10, 2015 at 7:58 PM, Baptiste <[email protected]> wrote:
>>
>> On Thu, Sep 10, 2015 at 4:05 PM, Sourav Das <[email protected]>
>> wrote:
>> > Hi,
>> >
>> > I have been going through the HAProxy documentation for my work which
>> > deals
>> > with scaling and load balancing for MQTT Brokers.
>> >
>> > However, I could not find any configuration regarding the Client
>> > Affinity
>> > where the routing of the MQTT traffic is done based on the topic present
>> > in
>> > the MQTT message. As MQTT is also carried over TCP, is it possible to
>> > use a
>> > pre-configured hook in HAProxy so that the traffic can be routed to the
>> > appropriate server based on the MQTT topic.
>> >
>> > At present I am not able to find out any hook which enables this to be
>> > done.
>> > I am a bit curious to know whether the support of MQTT is planned in
>> > future
>> > releases of HAProxy.
>> >
>> >
>> > Please let me know if this makes sense.
>> >
>> > Regards,
>> > Sourav
>>
>>
>> Hi Sourav,
>>
>> This would be doable only if the information can be retrived from the
>> payload of the first request sent by the client.
>> could you provide more information about how MQTT protocol works? Is
>> there any server banner?
>> A simple TCP dump containing an example of the message you want to
>> route would be appreciated and allow us to deliver you an accurate
>> answer.
>>
>> Baptiste
>>
>>
>

Reply via email to