Cannot connect to stomp using stompjs

134 views Asked by At

I am trying to connect to my springboot stomp end points with stompjs library

Here is the client code;

const client = new Client({ brokerURL: "ws://192.168.179.77:8080/gs-guide-websocket", onConnect: () => { console.log("mekwth wd krpnko oi"); client.subscribe("/topic/greetings", (message) => console.log(Received: ${message.body}) ); client.publish({ destination: "/topic/hello", body: "First Message" }); }, debug: (err) => { console.log(err); }, });

client.activate();const client = new Client({
  brokerURL: "ws://192.168.179.77:8080/gs-guide-websocket",
  onConnect: () => {
    console.log("mekwth wd krpnko oi");
    client.subscribe("/topic/greetings", (message) =>
      console.log(`Received: ${message.body}`)
    );
    client.publish({ destination: "/topic/hello", body: "First Message" });
  },
  debug: (err) => {
    console.log(err);
  },

});

client.activate();

for this I got the folllowing output

LOG Opening Web Socket... LOG Web Socket Opened... LOG >>> CONNECT accept-version:1.2,1.1,1.0 heart-beat:10000,10000

After this no response were recieved. Why it does not connect to the stomp end point. i tried so many things but still no luck with any of them

I tryied using postman to connect to the websocket and it works. the issue is in the stomp part.

1

There are 1 answers

0
Senith Uthsara On

after going through some articles I found out that there is an issue with react native when using stompjs.

following article helped me to figure out the issue: React-native-null-choping

After following the article, I was able to get rid of the issue by setting the following attributes in the stomp client

forceBinaryWSFrames: true,
appendMissingNULLonIncoming: true,