WAMP fails with JSON error for binary messages
Categories
(DevTools :: Netmonitor, defect, P4)
Tracking
(Not tracked)
People
(Reporter: Harald, Unassigned)
References
Details
What were you doing?
- Open Network panel on https://crossbar.io/ and select the WS
- Inspect binary messages, like
1dTm
What happened?
UI doesn't update.
16:23:54.078 SyntaxError: JSON.parse: unexpected keyword at line 1 column 1 of the JSON data serializers.js:36:17
Which leads to return JSON.parse(payload);
What should have happened?
Preview data, which is probably msgpck
.
Anything else we should know?
The client requests wamp.2.json, wamp.2.msgpack
while the server responds with wamp.2.json
. This might also be a server issue, but lets verify.
Reporter | ||
Comment 1•3 years ago
|
||
Tobias, the server seems to send binary message on a connection that agreed on JSON. Is this something that the parser should handle?
Reporter | ||
Updated•3 years ago
|
Comment 2•3 years ago
|
||
These frames don't appear in Chrome. Also other WAMP clients don't seem to receive them. Maybe these are PING/PONG frames or something like that?
Elad
Reporter | ||
Comment 3•3 years ago
|
||
Right, I also see that they didn’t trigger the site onmessage handler (tested using the new event breakpoints), so something is definitely fishy.
Comment 4•3 years ago
|
||
I can reproduce the issue on my machine.
I am also seeing the following error sin the Browser Console, not sure if it's related:
Error sending event: serverWebSocketClosed Actor.js:68:15
_sendEvent resource://devtools/shared/protocol/Actor.js:68
initialize resource://devtools/shared/protocol/Actor.js:46
_emit resource://devtools/shared/event-emitter.js:226
emit resource://devtools/shared/event-emitter.js:172
emit resource://devtools/shared/event-emitter.js:324
webSocketClosed resource://devtools/server/actors/network-monitor/websocket-actor.js:96
Error: "undefined passed where a value is required"
identityWrite resource://devtools/shared/protocol/types.js:115
write resource://devtools/shared/protocol/Request.js:117
write resource://devtools/shared/protocol/Request.js:43
_sendEvent resource://devtools/shared/protocol/Actor.js:66
initialize resource://devtools/shared/protocol/Actor.js:46
_emit resource://devtools/shared/event-emitter.js:226
emit resource://devtools/shared/event-emitter.js:172
emit resource://devtools/shared/event-emitter.js:324
webSocketClosed resource://devtools/server/actors/network-monitor/websocket-actor.js:96
Honza
Comment 5•3 years ago
|
||
In the meantime, I had a chance to test this feature on Firefox 74 release: https://github.com/wamp-proto/wamp-proto/issues/362#issuecomment-597250065
Also, let me comment on a few of the aspects raised in above, as well as add more;)
The client requests wamp.2.json, wamp.2.msgpack while the server responds with wamp.2.json. This might also be a server issue, but lets verify.
This is expected behavior for a WAMP compliant router, as ["wamp.2.json", "wamp.2.msgpack"]
is interpreted by the router as a list of WebSocket subprotocol the client is able to talk - ordered by preference! So the router will choose the first one it supports.
These frames don't appear in Chrome. Also other WAMP clients don't seem to receive them. Maybe these are PING/PONG frames or something like that?
Yes, I believe so! The reason is from looking at the message traces here https://github.com/wamp-proto/wamp-proto/issues/362#issuecomment-597487761 - I know this router is doing websocket-server-initiated ping-pong with 10s interval.
If the current code isn't able to handle control frames but tries to treat them as websocket message frames, trying to parse WAMP, be that wamp-json or wamp-msgpack, that must fail. The ping/pong payload that eg Crossbar.io sends is just a configurable chunk of random bytes, that is expected to be replied by the client (Firefox) in a websocket pong. There is nothing to interpret in the ping payload at least for Crossbar.io
However, IMO, it would be cool to just skip control frames without interpretation, because the only case when one might be interested in the websocket control frame level is for maintainers of the websocket implementation within Firefox? Not sure about that .. it would be certainly nice to have control frames show up upon clicking an option in the network inspector .. but, yeah, for me, the 99% case of interest is websocket message(s) / frames .. parsed and shown at the application layer (here, WAMP).
Comment 6•3 years ago
|
||
when looking at these lines
https://hg.mozilla.org/mozilla-central/rev/3af87b72a2b4#l1.79
getFramePayload(selectedFrame.payload, connector.getLongString).then(
async payload => {
const { formattedData, formattedDataTitle } = await this.parsePayload(
``
* Is this firing for each received websocket message?
* For each control or data message?
If so, then `selectedFrame` can be called with a control frame, and the further processing in `parsePayload` doesn't seem to be ready for control frames?
Is there some `selectedFrame.frame_type` attribute maybe which we could use?
I am guessing a lot in above;) just my 2cts
Reporter | ||
Comment 7•3 years ago
|
||
Thanks a lot for digging into this, Tobias!
Makes sense that formatting should simply not be applied to control frames. I will track this in a more specific bug. Not showing control frames is tracked in bug 1566780.
Reporter | ||
Comment 8•3 years ago
|
||
Better to dupe it, a this specific issue got a bit convoluted.
Comment 9•3 years ago
|
||
Makes sense that formatting should simply not be applied to control frames.
yes, I think calling the websocket subprotocol parsing code (like for wamp) only for websocket data traffic, and for whole websocket data messages is much better
I don't know enough about the FF internals, but one thing I would worry about as a consequence of ^:
- if the inspector should also have the option to show control frames in addition to the subprotocol-parsed data messages, then the inspector traffic pane must be able to show a mix of control frames and parsed data messages, where the former comes from FF common code, while the latter comes from subprotocol-parsing code. Sounds like it could be tricky at least?
- if the inspector doesn't have the option to show any control traffic at all, everything seems to become straight-forward and simple;)
Description
•