stomp-js / stompjs

Javascript and Typescript Stomp client for Web browsers and node.js apps
Apache License 2.0
773 stars 82 forks source link

Websocket infinite reconnection loop #485

Closed mlazarenkoivy closed 1 year ago

mlazarenkoivy commented 2 years ago

Hi! I have the infinite reconnection loop. I've read the documentation. I've tried to do everything according to it but I still have this reconnection loop

const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const fs = require('fs');
const path = require('path');

const app = express();

Object.assign(global, { WebSocket: require('websocket').w3cwebsocket });

var StompJs = require('@stomp/stompjs');

const client = new StompJs.Client({
  brokerURL: 'ws://localhost:3001/stream/ws',
  debug: function (str) {
    console.log(str);
  }
});

client.onConnect = function (frame) {
  console.log('Connection STOMP from nodejs openned');
};

client.onStompError = function (frame) {
  console.log('Broker reported error: ' + frame.headers['message']);
  console.log('Additional details: ' + frame.body);
};

client.activate();

app.listen(3001, () => console.log('Mock server listening on port 3001'));

image

kum-deepak commented 2 years ago

The above indicates that the broker connection is not getting opened. You should check if the broker is configured correctly and if the URL is correct.

mlazarenkoivy commented 2 years ago

I didn't configure any broker. I have to use additional third party library for STOMP broker? (like what?)

kum-deepak commented 1 year ago

This library offers connections to a STOMP broker. Please configure a broker and then follow the guides to use it.