Skip to content
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

Error retrieving message content in large messages #13

Closed
aalbericio opened this issue Oct 3, 2018 · 4 comments
Closed

Error retrieving message content in large messages #13

aalbericio opened this issue Oct 3, 2018 · 4 comments

Comments

@aalbericio
Copy link

Hello,

I'm experiencing an issue when retrieving "large" messages using the latest 5.0.0-b4 version of the library.

The error is:

core.js:1673 ERROR SyntaxError: Unexpected end of JSON input
   at JSON.parse (<anonymous>)
   at MESSAGE (stomp-handler.js:54)
   at Parser.onFrame (stomp-handler.js:110)
   at Parser.push../node_modules/@stomp/stompjs/esm6/parser.js.Parser._retrievedBody (parser.js:171)
   at Parser.push../node_modules/@stomp/stompjs/esm6/parser.js.Parser._collectBodyFixedSize (parser.js:164)
   at Parser.push../node_modules/@stomp/stompjs/esm6/parser.js.Parser.parseChunk (parser.js:76)
   at WebSocket._webSocket.onmessage [as __zone_symbol__ON_PROPERTYmessage] (stomp-handler.js:119)
   at WebSocket.wrapFn (zone.js:1188)
   at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) 

I'm receiving a frame (like the one attached to this issue) that is bigger than 5Kb. The collectBodyFixedSize function is trying to collect the body but it's not succeding at all.

Running a JSON.parse(message.body) is failing and I can see that this function is not retrieving the whole set of bytes of the body: it's collecting all but the 2 latest characters ("[}") of the body, making the JSON.parse fail.

I can't not reproduce this bug in smaller messages (50, 100... bytes or so) and this bug is not present in older versions (4.0.8).

Is this a real bug? Am I doing something wrong? Is this an error related to this beta version?

Thanks in advance.

message.txt

@kum-deepak
Copy link
Member

I think I have an idea why it is happening.

As per STOMP standards, the content-length is length in octets (https://stomp.github.io/stomp-specification-1.2.html#Header_content-length). The version 4.0.8 has incorrect implementation.

I noticed the content-length in your frame is character length.

To get over it, the broker should send length in octets or should not send the content-length header at all.

@aalbericio
Copy link
Author

Aha,

We will look into the broker's implementation and provide some feedback in this thread. We're testing the new beta4 version and were surprised on this issue since the 4.0.8 version was running just fine (at least for us).

Thanks for your quick response, again.

@aalbericio
Copy link
Author

Hello Kum,

You were right: our middleware was sending the content lenght incorrectly.

Now it's fixed in our side and the only "input" for you is that version 4.0.8 had, somehow, an incorrect implementation.

Thanks again. I close this ticket.

@kum-deepak
Copy link
Member

kum-deepak commented Oct 5, 2018

In all previous versions frame parsing had multiple minor issues, which all together made it work for most regular use cases. However, there was no easy way to support binary content - which can have NULLs.

This was one of the main motivations for the new version.

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

No branches or pull requests

2 participants