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.

Stompjs works only in debug mode react-native

See original GitHub issue
 `const client = new Client({
      brokerURL: url
      orceBinaryWSFrames: true,
      appendMissingNULLonIncoming: true,
      logRawCommunication: true,
      reconnectDelay: 0, // disable auto reconnect
      debug: str => {
       console.warn(str);
     }
 });

` im using RN version: 0.59.9 and stompjs version : ^5.4.2

when the simulator is in debug mode the client gets connected otherwise nothing.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:23 (11 by maintainers)

github_iconTop GitHub Comments

4reactions
vipulchastacommented, May 25, 2020

@IlifilzaRusli @mattruddy You can add import statement in your index.js or App.js, anything will work fine. But make sure you have done changes for forceBinaryWSFrames & appendMissingNULLonIncoming also.

And one more thing I would like to add. (For Android development) If your connection to broker is not secured(you are not using any ssl certificate) then connection will not get established. You will find following error log in production build(you can use logcat in production build) but same will work perfectly in debug build.

Screenshot 2020-05-26 at 3 37 19 AM

To overcome from this issue you will have to add following line in your android manifest file to allow unsecure traffic. android:usesCleartextTraffic="true"

Reference: https://blog.usejournal.com/6-daily-issues-in-android-cleartext-traffic-error-52ab31dd86c2

By incorporating all four changes… my app is working fine with RabbitMQ broker, even in production build. Changes are: 1. Importing TextEncoder polyfill 2. Setting flags forceBinaryWSFrames & appendMissingNULLonIncoming to true 3. Allowing Unsecure outgoing traffic for the app. 4. Setting “web_stomp.ws_frame = binary” on RabbitMQ broker config [I don’t think it is required. After doing all four changes I verified my app, and it was working. But I have not tried without this change]

Thanks @kum-deepak from great documentation.

1reaction
orhangazicommented, Oct 20, 2021

I did the first and second steps and it work. Thank you so much.

  1. Importing TextEncoder polyfill (app.js or index.js)
  2. Setting flags forceBinaryWSFrames & appendMissingNULLonIncoming to true (add both into the stomp configure)

@IlifilzaRusli @mattruddy You can add import statement in your index.js or App.js, anything will work fine. But make sure you have done changes for forceBinaryWSFrames & appendMissingNULLonIncoming also.

And one more thing I would like to add. (For Android development) If your connection to broker is not secured(you are not using any ssl certificate) then connection will not get established. You will find following error log in production build(you can use logcat in production build) but same will work perfectly in debug build.

Screenshot 2020-05-26 at 3 37 19 AM

To overcome from this issue you will have to add following line in your android manifest file to allow unsecure traffic. android:usesCleartextTraffic="true"

Reference: https://blog.usejournal.com/6-daily-issues-in-android-cleartext-traffic-error-52ab31dd86c2

By incorporating all four changes… my app is working fine with RabbitMQ broker, even in production build. Changes are: 1. Importing TextEncoder polyfill 2. Setting flags forceBinaryWSFrames & appendMissingNULLonIncoming to true 3. Allowing Unsecure outgoing traffic for the app. 4. Setting “web_stomp.ws_frame = binary” on RabbitMQ broker config [I don’t think it is required. After doing all four changes I verified my app, and it was working. But I have not tried without this change]

Thanks @kum-deepak from great documentation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

StompJs only works in debugging mode - React Native
The connection between the StompJs over WebSocket is established only when the app is in debugging mode. react-native · websocket · stompjs.
Read more >
Developers - Stompjs works only in debug mode react-native -
when the simulator is in debug mode the client gets connected otherwise nothing. See More. View in GitHub. SOLVE ISSUE.
Read more >
Using STOMP JS
Read along to learn how to use the Stomp object. Create a STOMP client. STOMP JavaScript clients will communicate to a STOMP server...
Read more >
React native app only works with debug enabled? - Reddit
Once debug is enabled and there's a connected debugger (Chome or Firefox), the app works normally. Any idea why this is happening?
Read more >
STOMP Over WebSocket
It is aimed to run on the WebSockets protocol which is not TCP. ... By default, stomp.js will use the Web browser native...
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