-
Notifications
You must be signed in to change notification settings - Fork 100
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
Rsocket Websocket Client - issue with composite metadata at browsers #72
Comments
Hello @maxim-bandurko-lsvt! Thanks for reporting the issue! I would like to clarify, did you use the example for the repository and it did not work well for you? Regards, |
Oh yeah! I see. I tested that with the node, but the node has a native Buffer that works differently. So, due to the node Buffer spec, the default encoding is UTF-8, that is basically why I ignored the rest of params, but the polyfill that we keep for browser missing that one. So, good catch up! Thank you for reporting that! |
@maxim-bandurko-lsvt created a PR |
@OlegDokuka Thank you! |
Hi @OlegDokuka with js client with composite metadata
Rsocket springboot server throws an exception for routing metadata
|
@nofelkad Fix is inside the gitgub master branch already, but @OlegDokuka would be nice if it can go to PR also. |
@maxim-bandurko-lsvt i have incorporated this changes. This error is post that. Prior i was getting the same error for which this issue was opened (TypeError: Unknown encoding: undefined). |
@nofelkad I am getting the same issue with spring boot:
Using simple MessageMapping in controller:
@OlegDokuka I assume that implementation of Composite Metadata is not implemented yet? |
WS messages dump:
|
@OlegDokuka @nofelkad Just figured out that example at: Line 65: Buffer should include the length for route before actual route. |
According to comment: rsocket#72 (comment) Tested on our own code base.
According to comment: #72 (comment) Tested on our own code base.
@maxim-bandurko-lsvt can you please check if this is still an issue in the latest rsocket release? |
@OlegDokuka Sure! |
@OlegDokuka Can't make it working any more. Latest JS client release 0.0.23 with latest Spring Boot release 2.5.0 (M1). Used your example from rsocket/rsocket#281: if have metadata as a buffer like in your sample, it just disconnects client from server. If passing just Old example with Only JS client release 0.0.19 is most stable one that works with Java server. |
@maxim-bandurko-lsvt do you have something that I can reproduce locally to see what is going wrong. |
@OlegDokuka I did example for you using more recent versions of Webpack with core-js and added "buffer" module (as it's polyfill was dropped from Webpack v5 #110 ), and all started working properly! So issue is with my JS frameworks and I need to switch version of Webpack from v4 to v5. Anyway, attaching example of JS client with Java server, in case if somebody needs simple example for composite metadata with binary mime type. The only thing is that can't remind myself how exactly to extract those metadata from message inside the
|
@OlegDokuka Just did all updates at my JS framework builds and everything works as a charm! I know, may be this thread is not correct one for a question about extracting composite metadata at MessageMapping in Spring Java, but will be very thankful to you with guide on this. |
@maxim-bandurko-lsvt, just FYI, we have our own buffer polyfill, thus adding an external one is redundant |
@OlegDokuka Yes, and with previous versions it was used as a substitution on default. Coming from #110 it is not included on default as I see. This actually can be confusing, as it works for Node, but doesn't work for browser app and depends on 3 options how to make it working. I think it makes sense to come with new Buffer abstraction similar to Honestly, wish JS had all those framework that Spring has! |
@maxim-bandurko-lsvt have no idea, looks like it is your webpack setup. Here is the example where there are no other Buffer polyfill included -> https://github.com/OlegDokuka/rsocket-crosslanguage-example/blob/master/js-client/webpack.config.js and only lite-buffer impl is used as a Buffer polyfill. In any case, I'm working toward excluding litebuffer from the core at all. Please see #112 |
@OlegDokuka those example is not working. Any way #112 is good idea. Also, just tested passing encoded data by
So, the actual encoding way can be used in data and anybody can go with "JSON less" payload with composed multiple data chunks in RSocket. Server got:
How can we extract those data from |
Can you please point (error, etc) what does not work for you in my example since it "works on my machine" ™️ |
Also, can you clarify please, what do you mean by 'JSON less' ? Any pointers in the code? Also, composite metadata is note supposed to be passed as data in a payload. Though, in rsocket-Java, there is a CompositeMetadata class which may decode given ByteBuf |
It hasn't any errors. It just get connected to Java server and nothing more after that. WS messages dump has only connection message:
no more messages. I've cleaned up 'node_modules' and did install again. It is still the same. |
Yep, composite metadata inside
|
Sometimes payloads can be very huge and consist not only with simple short strings, numbers, booleans. They may have dozen thousands lines of plain text, base64 data, etc. Common tactic is just serialize that into JSON at client and deserialize that to object at server (or reverse direction if that is response). And that is normal in terms of small payloads, but when payload is getting huge part of just string data that no need to be serialized (as it is just huge string) and size of this payload gets in megabytes and such payloads are very often in application, that takes a lot of resources to both server and client because of serialization and deserialization. To help make such requests processing logic cheaper a lot of developers starting using array of buffers that is can say "composited" into one payload buffer using certain byte as a delimiter. That works, but not very convenient, as it is needed to create small factories to each payload as to get correct types of properties values in payload and do object mapping in some way. So, it is very straight forward to have some kind "CompositeBuffer" that keeps buffer indexes with key representation and value type in the head of this buffer. Encoder makes this header and adds to top of buffer and decoder extracts the header, parses structure by index for each key and allows to extract all property keys converted to correct type, and finally map that to object if that is needed for convenient usage. I understand that RSocket uses such principe of encoding composite metadata for another things, but it worked very well out of box just for data on both javascript and Java sides ;) |
think about composite metadata as of HTTP headers. Do you ever encode your logical message inside heders?
Yeah. As you wish :D |
Hello.
With new release 0.0.18 were implemented Composite Metadata:
#49
Was trying to start using it and got to issue with composite metadata when using rsocket websocket client at browsers:
TypeError: Unknown encoding: undefined
in LiteBuffer.js at line 255
@OlegDokuka Can you please check these screenshots:
As it looks like at CompositeMetadata.js at line 191:
const customMimeLength = metadataHeader.write(customMime, 1);
is needed 2 more parameters.
I had used example from:
https://github.com/rsocket/rsocket-js/blob/master/packages/rsocket-examples/src/CompositeMetadataExample.js
Thank you.
The text was updated successfully, but these errors were encountered: