Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Protobuf support #21

Open
pantonis opened this issue Aug 9, 2016 · 16 comments
Open

Protobuf support #21

pantonis opened this issue Aug 9, 2016 · 16 comments
Labels

Comments

@pantonis
Copy link

pantonis commented Aug 9, 2016

Is this library compatible with protobuf?

Thanks.

@JSteunou
Copy link
Owner

JSteunou commented Aug 9, 2016

It does not use protobuf, but you can use protobuf above it. This client is quite low-level, so I do support only what the STOMP spec support.

@pantonis
Copy link
Author

pantonis commented Aug 9, 2016

I can see from the source that everything is converted into string.

this.ws.onmessage = (evt) => {
            let data = evt.data;
            if (evt.data instanceof ArrayBuffer) {
                data = typedArrayToUnicodeString(new Uint8Array(evt.data));
            }

If the data is converted into string I cannot deserialize it then using protobuf js.

@JSteunou
Copy link
Owner

JSteunou commented Aug 9, 2016

Going through String is mandatory in order to decode the STOMP frame.

@pantonis
Copy link
Author

pantonis commented Aug 9, 2016

what about going through string for headers and leave the body intact for further processing by the protobuf library?

@JSteunou
Copy link
Owner

JSteunou commented Aug 9, 2016

Could you show me how you would do that? A clean PR (pull request) could help.

@pantonis
Copy link
Author

pantonis commented Aug 9, 2016

Have a look at the following:

How-to-read-binary-data-in-the-browser-or-under-node.js

@JSteunou
Copy link
Owner

JSteunou commented Aug 9, 2016

This is not XHR protocol with HTTP, it's websocket with STOMP frames.

@pantonis
Copy link
Author

pantonis commented Aug 9, 2016

When reading/writing binary data in the browser or under node.js, it is mandatory to understand that just reading it (as a string) is not enough. When doing this, the data will probably become corrupted when it is converted between character sets and ProtoBuf.js will not be able to decode it or will return random stuff. What's actually required here is to properly handle the data as binary.

It is still read as string. So corruption happens when original body contect is read as string.

@pantonis
Copy link
Author

pantonis commented Aug 9, 2016

I have seen the same problem and suggestion I wrote here in this thread but it seems that it is not maintained anymore

stomp-websocket

@JSteunou
Copy link
Owner

JSteunou commented Aug 9, 2016

This is fixed in this fork

@pantonis
Copy link
Author

pantonis commented Aug 9, 2016

adamish commented on Dec 10, 2014 comment is fixed here?

@pantonis
Copy link
Author

Hi,

I get the following error when using protobuf

image

@pantonis
Copy link
Author

??

@pantonis
Copy link
Author

pantonis commented Aug 17, 2016

I can confirm that this was not fixed as you stated.

@idcmp
Copy link

idcmp commented Jul 3, 2018

Spring 5.0.7+ recommends this variant of the STOMP library for browser clients, and while it's possible to send binary via this library (and the Spring implementation of STOMP is binary safe), this issue prevents developers from sending binary replies.

So without some massaging on the server, protobuf is not supported.

That said, I'm not sure if this library is still the best fork for developers to use.

@JSteunou
Copy link
Owner

JSteunou commented Jul 3, 2018

This fork matches my need, but you are welcome to contribute via PR ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants