Open Bug 1590849 Opened 5 years ago Updated 2 years ago

Preview MessagePack format in WebSocket Inspector

Categories

(DevTools :: Netmonitor, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: Harald, Unassigned)

References

(Blocks 2 open bugs)

Details

User Story

When debugging binary MessagePack-based WebSocket connections, I want the inspector to decode the messages, so that can inspect the JSON data.

Attachments

(1 file)

User Story: (updated)

I would like to work on this.

From what I gather, the file that requires changes is this: https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/src/components/websockets/FramePayload.js

if we use the above mentioned library: https://www.npmjs.com/package/msgpack-lite
can you please tell me how should I start using it (a don't see a node_modules folders :p and I am a total newbie ).

if not, how can I start making the parser?

Thanks in advanced.

nishant nimbare, you should be able to re-use a newly added msgpack library that got added for WAMP in bug 1566755: https://phabricator.services.mozilla.com/D58075#change-XY2bV43l8Pnd

Flags: needinfo?(nishantnimbare)
Assignee: nobody → nishantnimbare
Status: NEW → ASSIGNED

Hi,

I tried to play around with the code.
one of the problems seems to be that the "Sec-WebSocket-Protocol" header may not be present in the response and thus the code is not checking for msgpack https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/src/components/websockets/FramePayload.js#124

any ideas how to go ahead?

I tried to loop through all the WAMP serializers and try each one but there there is some error which throws up which I am trying to understand.
error : messageArray is not iterable
In: https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/src/components/websockets/parsers/wamp/arrayParser.js

Thanks.

one of the problems seems to be that the "Sec-WebSocket-Protocol" header may not be present in the response

The header, in this case, isn't useful as this is only used in WAMP. This bug is about use cases of msgpack for message encoding outside of WAMP.

You probably want to start by checking if the binaryType on the WS connection is set to "arraybuffer": https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/binaryType. This would make the data an arraybuffer which you can load into a Uint8Array and hand into msgpack https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/src/components/websockets/msgpack.js#23

This should be try-catch wrapped, as we don't know if the data is msgpack formatted but hopefully fails early.

Hope that helps.

Flags: needinfo?(nishantnimbare)

I tried working on this bug.
I decoded the messagepack and converted it to JSON using the deserialize method present in msgpack.js file (which is being used also for wamp.2.msgpack deserializing).

Now before I submit my patch, I wanted to test it.
I went to this website: http://signalr-samples.azurewebsites.net/hubs.html
Select msgpack and Connect.

Unfortunately, the conversion failed!
So I thought of checking what happens in Google Chrome. Here is a screenshot attached.
Now when I try to decode this binary message manually from msgpack to JSON it still doesn't give the proper JSON.
Meaning, I "guess" the message received should have been decoded as {"type": 6} but when I convert the hex 02 91 06 here it gives something else.

(NB: Why I guess the message should have been decoded as {"type": 6} because this is the JSONHub message received when JSON is selected instead of msgpack)

Now, I don't know if I am making some mistake in the conversion or if the website itself is sending incorrect messages.
So, does anyone know of a different website where I can test msgpack conversion?

Flags: needinfo?(kishlaya.j)

(In reply to Kishlaya from comment #5)

I tried working on this bug.
I decoded the messagepack and converted it to JSON using the deserialize method present in msgpack.js file (which is being used also for wamp.2.msgpack deserializing).

Now before I submit my patch, I wanted to test it.
I went to this website: http://signalr-samples.azurewebsites.net/hubs.html
Select msgpack and Connect.

Unfortunately, the conversion failed!
So I thought of checking what happens in Google Chrome. Here is a screenshot attached.
Now when I try to decode this binary message manually from msgpack to JSON it still doesn't give the proper JSON.
Meaning, I "guess" the message received should have been decoded as {"type": 6} but when I convert the hex 02 91 06 here it gives something else.

(NB: Why I guess the message should have been decoded as {"type": 6} because this is the JSONHub message received when JSON is selected instead of msgpack)

Now, I don't know if I am making some mistake in the conversion or if the website itself is sending incorrect messages.
So, does anyone know of a different website where I can test msgpack conversion?

Flags: needinfo?(kishlaya.j) → needinfo?(odvarko)

Thanks for helping with this Kishlaya!

Kishlaya, can you please also attach your patch so, we can see what exactly are you doing (and perhaps also try on our machines)
(doesn't matter if the patch is just work in progress)

Thanks!

Honza

Flags: needinfo?(odvarko) → needinfo?(kishlaya.j)

Kishlaya, can you try to do the paylod parsing directly on the backend?

Here is the place where we access received/sent frame payload:
https://searchfox.org/mozilla-central/rev/4d9cd186767978a99dafe77eb536a9525980e118/devtools/server/actors/network-monitor/websocket-actor.js#100,126

It's possible that binary data are mangled when sent (over RDP) to the client side (net panel). So, trying it directly on the backend might work.

Honza

Hi Kishlaya,
you are assigned to this bug, but there is no activity for a long time.
Please let us know if you have any problems or questions.

Are you still planning to work on this?
Honza

Apologies for being inactive on this.

So I tried the following:
I converted the payload to binary string (on the backend - both before it gets wrapped into a longstringactor and after) and dumped it on my system-log. The output matches exactly the output when the same is done on the net-panel directly.

Flags: needinfo?(kishlaya.j)

The bug assignee didn't login in Bugzilla in the last 7 months.
:Honza, could you have a look please?
For more information, please visit auto_nag documentation.

Assignee: nishantnimbare → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(odvarko)

Still something we want, but not a priority for the team atm.
If anyone is intersted working on this, patches are welcome!

Honza

Flags: needinfo?(odvarko)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: