-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP REST bridge should use Autobahn's binary enabled JSON serializer #2089
Comments
Hi!
ok, that's not ok;)
class IOW, it's important to recognize, you are using 2 advanced features in combination: WAMP meta API and accessing that WAMP API over HTTP/REST via the bridge. that should work of course - but you run into an issue. the 1st piece is the WAMP meta API itself, which is here: crossbar/crossbar/router/service.py Line 232 in 03d7057
I would hence first test your exact situation and exact session ID which you want to get info on using the WAMP meta API over regular WAMP - take out the REST bridge as source of error. and check if the returned information contains any binary items. what client language are you using? you can use/adjust this python example: https://github.com/crossbario/crossbar-examples/blob/master/metaapi/monitor-sessions.py |
Thanks for the answer and the example! I could finally determine my problem, which was entirely my fault. I found the culprit in the end by overwriting the However, a catch of these serialization errors is probably necessary, so that no network timeout occurs on the client side. Thanks again! |
ahhh, right, ok! this is interesting .. because: you might or might not have noticed that WAMP itself (both in Crossbar.io and in Autobahn) is able to use binaries in JSON ( it will automatically translate binary values to hex encoded strings for app payload items - or also authextra the code for this autotranslation is here: https://github.com/crossbario/autobahn-python/blob/master/autobahn/wamp/serializer.py#L436
BUT: for reasons unclear / historical the REST bridge in Crossbar.io does NOT use above function, but uses: crossbar/crossbar/bridge/rest/caller.py Line 12 in 03d7057
Line 78 in 03d7057
so to sum up, the actual bug is: the REST bridge should use the Autobahn JSON serializer! but in addition to that root issue, I also agree with
the exception should be caught in the bridge, and an "internal error" http 500 should result |
wamp.session.get
call via HTTP Bridge Caller results in error
Maybe nice to know for anyone running into this problem: |
ok, I've dug a bit deeper:
thus: if you had used a binary value inside my lesson from all of this is (again): we've reached a point where the protocol and implementation is complex enough that we really need more test coverage for all these things;) |
everything outside application payloads (of calls, events, ..) in WAMP messages on the wire must not use binary. I've pinged @ecorm to double check. if so, and if it goes out onto the wire in crossbar, then this is also a bug:( |
It depends on how one interprets the terms types and string in this Section 2.2 passage:
NUL is a valid character that may appear anywhere in a Unicode string. So when we prefix a NUL character to Base64-encoded binary data, the result is still a valid UTF-8 string. If "string" means any "UTF-8 string appearing over the wire", then the special way that WAMP converts binary data into strings for JSON serialization could be considered a "string" type. If "type" means the type at the WAMP layer after performing UTF-8-to-binary-data conversions, then I guess that would exclude the possibility of using binary data in the non-payload parts of WAMP messages. |
thanks for checking, and for your thoughts!
agreed, I was afraid that might be the case;) what is also missing (unless I overlooked it in the current spec text) is any explanation / motivation for this, which might give the reader additional context to disambiguate, which is one reason I am big fan of "use cases" and "motivations" and "goals" in tech specs. IOW: we are missing sth in the spec. having said that, here is some original motivation: all WAMP message elements other than and hence those WAMP message elements might need to be or potentially can be interpreted by e.g. a router and hence are kinda "important", and it makes sense to keep things simple and "least common denominator" from serialization PoV, and remove potential issues in that part now that is the motivation and goal. here is the "means" of achieving that: only use types which are directly present in all serializers, and only types which perfectly round-trip across for a single serializer and between serializers and those types mentioned in section 2.2. are exactly that. e.g. even though some serializers directly support binary types, not all do of course (well, and our JSON binary encoding is working perfectly, it is not a commonly used standard outside WAMP) here is another one: IEEE 754 floats do NOT roundtrip even for a single implementation or serializer. in fact, the IEEE 754 standard leaves open big areas undefined. same as with C.
I am almost sure the following is true: NUL is a valid unicode character, which "ends" a string, but which may appear zero, one or multiple times in unicode strings, and unicode implementations will only "consume" the string up to the first occurrence of NUL but "consume" .. is of course where the "details" begin;) eg consider this:
this is different from how plain C would treat above. surprised? I knew that .. and I hate it: why can't people write precise and complete specs? sure, gödel, incompleteness and all that. but above could have been properly defined, similar for IEEE 754. of course it never will be ... we'll be stuck with "\0" means "something" .. or not. anyways;) it works. good enough. |
Your motivation makes perfect sense and I agree with it.
WAMP's JSON binary encoding scheme was a bit problematic for me: The serialization library already had an option to Base64-encode binary data, but I had to hack it so that the NUL character could be read/written before the Base64 portion. Fortunately, the library provided enough hooks so that it didn't require me to modify its source code. But the hack is a bit ugly because I ended up implementing my own context stack in parallel to the one used internally by the serialization library.
For JSON, IEEE 754 floats can roundtrip if you use a library that takes care to output sufficient decimal digits (and handle I think what you meant is that you cannot rely on IEEE 754 float serialization/deserialzation to be lossless in general, when multiple implementations are involved.
As far as I can tell, the Unicode standard itself does not mandate how the NUL character is supposed to be used, other than it being a "string terminator". From p. 916 of the specification:
|
thanks again for your thoughts! I fully agree rgd binary and unicode. and thanks for digging out the unicode spec text. interesting! rgd IEEE 754 (fav topic of mine;), things are more complicated I'm afraid, or let's say, I failed to communicate what I really meant. let me try again (sorry, character defect ... I have to;)
sure, between FLOAT_MIN and FLOAT_MAX, there are countable infinite many rational numbers (and uncountable infinite many real, but those are outside finite computers anyways), BUT only a finite subset of those numbers have a binary-float representation with the finite bits of exponent/mantissa in ANY case - this is the expected part. luckily, computing devices are also (usually) using binary floats, so there isn't a loss at that leg. BUT: NaN and inf are implementation defined in most of their bits. this was done intentionally - the designers intended to allow implementation to use the additional / undefined / implementation defined bits to signal the source or reason of NaN or inf. fwiw, here is how chatgpt 3.5 fails to get it, but then admits it is the case: Q: Correction: |
ChatGPT's correction seems like it was written by a human, which I guess it means that it passed the Turing Test in that particular case. 😁 |
Hi,
first of all, thank you for Crossbar and the whole WAMP Protocol.
I have a problem when I try to call
wamp.session.get
via the HTTP Caller with the following request:The call results in a network timeout and the following error log on the router:
I am not sure what classname is is being serialized.
According to the example in the source here there are no obvious classnames to me.
I am using a dynamic authenticatior similar to the provided examples, if that helps.
The text was updated successfully, but these errors were encountered: