Problems with my attach message

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems with my attach message

Dirkjan Ochtman
Hi there,

I'm trying to implement AMQP 1.0 in Rust from scratch because I'd like my
Rust service to be able to talk to an Artemis broker. I've been making good
progress, but am hitting some trouble now that I'm trying to send the
attach performative after bringing up the session.

This is what I'm sending:

    AmqpFrame {
        channel: 0,
        extended_header: None,
        performative: Attach(
            Attach {
                name: "vx-web-0",
                handle: 0,
                role: Sender,
                snd_settle_mode: None,
                rcv_settle_mode: None,
                source: None,
                target: Some(
                    "RPC",
                ),
                unsettled: None,
                incomplete_unsettled: None,
                initial_delivery_count: None,
                max_message_size: None,
                offered_capabilities: None,
                desired_capabilities: None,
                properties: None,
            },
        ),
        body: [],
    }

which is then encoded (not quite optimal, but seems to be correct per the
spec) as

[0, 0, 0, 70, 2, 0, 0, 0, 0, 163, 16, 97, 109, 113, 112, 58, 97, 116, 116,
97, 99, 104, 58, 108, 105, 115, 116, 208, 0, 0, 0, 38, 0, 0, 0, 14, 161, 8,
118, 120, 45, 119, 101, 98, 45, 48, 67, 163, 6, 83, 101, 110, 100, 101,
114, 64, 64, 64, 161, 3, 82, 80, 67, 64, 64, 64, 64, 64, 64, 64]

In response I receive

    AmqpFrame {
        channel: 0,
        extended_header: None,
        performative: Close(
            Close {
                error: None,
            },
        ),
        body: [],
    }

When I leave out the target from the attach message, I get a
NullPointerException error instead, apparently from
AMQPSessionContext.addReceiver() -- but when I add the target, any
breakpoints I set in that method aren't even hit. This has me quite
confused (it would have been nice if there was an actual error message
here). I fully expect the problem to be in my code, but would appreciate
any hints towards debugging the problem. I've been trying to get Wireshark
to decode the protocol, but having no luck so far. A pcap with a minimal
successful session might be quite helpful as well, if I'd be able to get
Wireshark to decode it correctly.

Any help would be much appreciated!

Kind regards,

Dirkjan
Reply | Threaded
Open this post in threaded view
|

Re: Problems with my attach message

tabish121@gmail.com
On 12/12/19 3:08 PM, Dirkjan Ochtman wrote:

> Hi there,
>
> I'm trying to implement AMQP 1.0 in Rust from scratch because I'd like my
> Rust service to be able to talk to an Artemis broker. I've been making good
> progress, but am hitting some trouble now that I'm trying to send the
> attach performative after bringing up the session.
>
> This is what I'm sending:
>
>      AmqpFrame {
>          channel: 0,
>          extended_header: None,
>          performative: Attach(
>              Attach {
>                  name: "vx-web-0",
>                  handle: 0,
>                  role: Sender,
>                  snd_settle_mode: None,
>                  rcv_settle_mode: None,
>                  source: None,
>                  target: Some(
>                      "RPC",
>                  ),
>                  unsettled: None,
>                  incomplete_unsettled: None,
>                  initial_delivery_count: None,
>                  max_message_size: None,
>                  offered_capabilities: None,
>                  desired_capabilities: None,
>                  properties: None,
>              },
>          ),
>          body: [],
>      }
>
> which is then encoded (not quite optimal, but seems to be correct per the
> spec) as
>
> [0, 0, 0, 70, 2, 0, 0, 0, 0, 163, 16, 97, 109, 113, 112, 58, 97, 116, 116,
> 97, 99, 104, 58, 108, 105, 115, 116, 208, 0, 0, 0, 38, 0, 0, 0, 14, 161, 8,
> 118, 120, 45, 119, 101, 98, 45, 48, 67, 163, 6, 83, 101, 110, 100, 101,
> 114, 64, 64, 64, 161, 3, 82, 80, 67, 64, 64, 64, 64, 64, 64, 64]

Your encoding appears to go wrong when encoding the Role value as the
encoding code appears to be (163) which is the encoding code for 'Char'
while Role is expected to be a Boolean type.


> In response I receive
>
>      AmqpFrame {
>          channel: 0,
>          extended_header: None,
>          performative: Close(
>              Close {
>                  error: None,
>              },
>          ),
>          body: [],
>      }
>
> When I leave out the target from the attach message, I get a
> NullPointerException error instead, apparently from
> AMQPSessionContext.addReceiver() -- but when I add the target, any
> breakpoints I set in that method aren't even hit. This has me quite
> confused (it would have been nice if there was an actual error message
> here). I fully expect the problem to be in my code, but would appreciate
> any hints towards debugging the problem. I've been trying to get Wireshark
> to decode the protocol, but having no luck so far. A pcap with a minimal
> successful session might be quite helpful as well, if I'd be able to get
> Wireshark to decode it correctly.
>
> Any help would be much appreciated!
>
> Kind regards,
>
> Dirkjan
>

--
Tim Bish

Reply | Threaded
Open this post in threaded view
|

Re: Problems with my attach message

Dirkjan Ochtman
On Thu, Dec 12, 2019 at 11:59 PM Timothy Bish <[hidden email]> wrote:

> > which is then encoded (not quite optimal, but seems to be correct per the
> > spec) as
> >
> > [0, 0, 0, 70, 2, 0, 0, 0, 0, 163, 16, 97, 109, 113, 112, 58, 97, 116,
> 116,
> > 97, 99, 104, 58, 108, 105, 115, 116, 208, 0, 0, 0, 38, 0, 0, 0, 14, 161,
> 8,
> > 118, 120, 45, 119, 101, 98, 45, 48, 67, 163, 6, 83, 101, 110, 100, 101,
> > 114, 64, 64, 64, 161, 3, 82, 80, 67, 64, 64, 64, 64, 64, 64, 64]
>
> Your encoding appears to go wrong when encoding the Role value as the
> encoding code appears to be (163) which is the encoding code for 'Char'
> while Role is expected to be a Boolean type.
>

Thanks, I did miss that! This turned out not to fix the problem by itself.
I previously didn't know exactly what to do with the way the spec documents
source and target as being of the "*" type, but it turns out there are
described types for both of these. Implementing these managed to get me to
the next stage, where I get an attach performative returned from Artemis. I
also discovered https://qpid.apache.org/amqp/type-reference.html, which is
much easier to use than the spec PDF!

Can you give me some pointers as to where in the source code this level of
decoding happens for incoming message frames? That way, I might be able to
better resolve similar problems in the future.

Kind regards,

Dirkjan
Reply | Threaded
Open this post in threaded view
|

Re: Problems with my attach message

tabish121@gmail.com
On 12/13/19 3:25 PM, Dirkjan Ochtman wrote:

> On Thu, Dec 12, 2019 at 11:59 PM Timothy Bish <[hidden email]> wrote:
>
>>> which is then encoded (not quite optimal, but seems to be correct per the
>>> spec) as
>>>
>>> [0, 0, 0, 70, 2, 0, 0, 0, 0, 163, 16, 97, 109, 113, 112, 58, 97, 116,
>> 116,
>>> 97, 99, 104, 58, 108, 105, 115, 116, 208, 0, 0, 0, 38, 0, 0, 0, 14, 161,
>> 8,
>>> 118, 120, 45, 119, 101, 98, 45, 48, 67, 163, 6, 83, 101, 110, 100, 101,
>>> 114, 64, 64, 64, 161, 3, 82, 80, 67, 64, 64, 64, 64, 64, 64, 64]
>> Your encoding appears to go wrong when encoding the Role value as the
>> encoding code appears to be (163) which is the encoding code for 'Char'
>> while Role is expected to be a Boolean type.
>>
> Thanks, I did miss that! This turned out not to fix the problem by itself.
> I previously didn't know exactly what to do with the way the spec documents
> source and target as being of the "*" type, but it turns out there are
> described types for both of these. Implementing these managed to get me to
> the next stage, where I get an attach performative returned from Artemis. I
> also discovered https://qpid.apache.org/amqp/type-reference.html, which is
> much easier to use than the spec PDF!
>
> Can you give me some pointers as to where in the source code this level of
> decoding happens for incoming message frames? That way, I might be able to
> better resolve similar problems in the future.

Artemis doesn't do the decoding itself, it uses the proton-j library
from the Qpid project as the AMQP protocol engine and that is where
frames are decoded and processed.  The codec from proton-j is where you
can get some ideas on how to properly encode and decode the AMQP
performatives

https://github.com/apache/qpid-proton-j/tree/master/proton-j/src/main/java/org/apache/qpid/proton/codec

You can build some tooling for yourself using that library to validate
that your own client emits and consumes AMQP data appropriately.



> Kind regards,
>
> Dirkjan
>

--
Tim Bish