Workaround - React Native STOMP issue because NULL chopping
See original GitHub issueI was facing an issue where the stomp client doesn’t get connected to server because of the null terminator and the connect message wasn’t parsed at server side correctly because it was sent as string instead of binary array.
I did lots of debugging on it and the solution was to make isBinaryBody always true like so
FrameImpl.prototype.serialize = function () {
var cmdAndHeaders = this.serializeCmdAndHeaders();
if (this.isBinaryBody || true) { // to always return as binary array
return FrameImpl.toUnit8Array(cmdAndHeaders, this._binaryBody).buffer;
}
else {
return cmdAndHeaders + this._body + byte_1.BYTE.NULL;
}
};
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
React Native - Additional notes - StompJS Family
The approach is completely safe - it will not cause any data loss or incorrect protocol behavior. As of June 10, 2019, the...
Read more >React native: Stomp websocket not working in android
NULL ('\x00') as a last symbol. Android implementation of WebSocket cuts last char if it is Byte.NULL (seems like a bug). However WebSocket.send ......
Read more >stomp/stompjs - UNPKG
103, * A bug in ReactNative chops a string on occurrence of a NULL. ... 110, * This is not an ideal solution,...
Read more >Spring Boot Reference Documentation
Cutting edge snapshot distributions are also available. ... It can cause particular problems for Spring Boot applications that use the @ComponentScan ...
Read more >Unreal Engine 5.1 Release Notes
Bug Fix: Fixed an issue that could cause property access nodes to report an erroneous error when using split pins in functions. Fixed...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A flag is added in configuration
forceBinaryWSFrames
, this will make outgoing frames to be binary.Many thanks for this. I do not use React Native myself.
This was earlier reported as slightly different issue (https://github.com/stomp-js/stomp-websocket/issues/37). The underlying issue seems to be Reactive Native having issue with NULL characters in strings. NULLs in string are needed to support STOMP protocol. See: https://github.com/facebook/react-native/issues/12731
Based on your analysis it seems, sending messages in binary bypasses the issue. I will wait for your results - based on that an option (say
alwaysSendBinaryPackets
) may be added to the config.Making this change will control packets sent to the broker. However the communication may fail if the server sends a text packet. Some brokers (like RabbitMQ has an option to always send binary packets).