easternbloc / node-stomp-client

A STOMP client for Node.js
Other
93 stars 47 forks source link

(net.createConnection is not a function) error in React JS #84

Open Amin207 opened 1 year ago

Amin207 commented 1 year ago

Hi, using React js and got this error at the beginning. (The options are not right but atleast it could get me a callback error instead of net error.)

const Stomp = require("stomp-client");

const destination = "/queue/someQueueName";
const client = new Stomp("127.0.0.1", 61613, "user", "pass");

export default function StompTest() {
  client.connect(
    function (sessionId) {
      client.subscribe(destination, function (body, headers) {
        console.log(
          "This is the body of a message on the subscribed queue:",
          body
        );
      });

      client.publish(destination, "Oh herrow");
    },
    function (err) {
      console.log(err);
    }
  );
}