Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

Binary data is not handled #15

Open
francoisforster opened this issue Dec 30, 2011 · 9 comments
Open

Binary data is not handled #15

francoisforster opened this issue Dec 30, 2011 · 9 comments
Assignees

Comments

@francoisforster
Copy link

I'm sending the following bytes from java: 45,-113,4,-120 and on the node.js side I get:
45
65533
4
65533
for (i=0;i<message.body.length;i++) {
console.log(message.body.charCodeAt(i));
}

STOMP supports binary data, so I would expect it it be handled with Buffers instead of strings.

@ghost ghost assigned benjaminws Dec 30, 2011
@benjaminws
Copy link
Owner

I'll take a look at this. You're right though, if it's a bytes message, it should use buffers instead of strings.

@benjaminws
Copy link
Owner

Can you please try out branch issue-15 (https://github.com/benjaminws/stomp-js/tree/issue-15). All it does is convert the body of the message back to a buffer if it's detected that the message is a binary message (by the presence of content-length header).

@francoisforster
Copy link
Author

That doesn't help. The bytes are already lost in translation before that.

@benjaminws
Copy link
Owner

Doh, you're right. I'll try another approach. This whole codebase needs a major refactoring :(

benjaminws added a commit that referenced this issue Dec 30, 2011
… comes in off the socket. slice off the rest of the stuff and extract commands/headers
@benjaminws
Copy link
Owner

New approach will leave the buffer intact, only slicing out the command/header bits as needed. Can you pull it down and test it for yourself?

@benjaminws
Copy link
Owner

Looked at this again. Problem is more annoying that I initially thought. Working on a fix, though. Should have something cooked up tomorrow.

@francoisforster
Copy link
Author

The body is still not a buffer (it's a Frame) which still mangles up the bytes.

@benjaminws
Copy link
Owner

Right. Hence the last note. Will hopefully have a fix today. The problem is the way I'm handling the incoming buffer, trying to treat it as a string initially instead of a buffer. Needs some extra work to parse out what I need from the buffer (no niceties like split, indexOf, etc on a buffer).

@francoisforster
Copy link
Author

Greatly appreciate your work.

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

No branches or pull requests

2 participants