Sy Trung
Sy Trung

Reputation: 11

React native: Stomp websocket not working in android

I try use https://github.com/jmesnil/stomp-websocket and https://github.com/JSteunou/webstomp-client

My server use Spring-boot

Mycode:

var Stomp = require('stompjs/lib/stomp.js').Stomp;
let client = Stomp.client(url);
client.connect({}, function connectCallback(frame){
   console.log('OK')
}, (error) => {
   console.log('Error');
});

Both working with IOS but in android this can't connect with server.

Web Socket Opened...

CONNECT

accept-version:1.1,1.0

heart-beat:10000,10000

Whoops! Lost connection

Error

Upvotes: 1

Views: 4398

Answers (2)

Nikos T
Nikos T

Reputation: 106

Although this is an old question, it troubled me very much the last couple of days...

I had followed Viktor's solution (which was also mentioned in many other sources as well from the research I did) about Android implementation of WebSocket cuts last char if it is Byte.NULL and added to my server a wrapper for that extra character as most solutions suggest... but it still didn't work....

In the end it was a problem with my version of Android (9+) that does not allow clear text communication (i.e. no SSL) as mentioned here

Once, I added a self signed certificate on my development server it worked with no problems

Upvotes: 1

Viktor Yarmak
Viktor Yarmak

Reputation: 181

As mentioned by Max - problem is that android is not sending \x00.

Please check solution here https://stackoverflow.com/a/48623125/1869260

Upvotes: 1

Related Questions