question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Workaround - React Native STOMP issue because NULL chopping

See original GitHub issue

I 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:open
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
kum-deepakcommented, Jan 18, 2019

A flag is added in configuration forceBinaryWSFrames, this will make outgoing frames to be binary.

3reactions
kum-deepakcommented, Jan 1, 2019

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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found