66

I have the follow situation:

 var options = {
        protocols_whitelist : [ "websocket", "xhr-streaming", "xdr-streaming", "xhr-polling", "xdr-polling", "iframe-htmlfile", "iframe-eventsource", "iframe-xhr-polling" ],
        debug : false
    };

    var socket = new SockJS("/mmyurl/",undefined,options);
    var stompClient = Stomp.over(socket);
    stompClient.connect({
        company : "XXXXX"
    }, function(frame) {
        stompClient.subscribe('/topic/mytopic', function(message){ 
            var myitem = JSON.parse(message.body);

        });

all works fine, the problem is that on the javascript console is full of debug messages like this:

<<< MESSAGE
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:o6g660dt-113
destination:/topic/mytopic
content-length:411

And I want to disable the messages.

I tried to change some option and also tried to register simply:

var socket = new SockJS("/mmyurl/");

but it doesn't work.

Is there a way to disable the debug messages?

Any help is appreciated

J.R.
  • 2,335
  • 2
  • 19
  • 21

2 Answers2

120

Ok I found a solution.

I added this code:

stompClient.debug = null

In this way, the debug function is disabled.

J.R.
  • 2,335
  • 2
  • 19
  • 21
  • 19
    For anyone else coming here, the documentation (http://jmesnil.net/stomp-websocket/doc/) states that you can set client.debug to any function, and that function gets run with each message. So in addition to being able to set debug to `null` you can change it to any function to manage your own debugging (set it by a GET variable or anything you want) – Dave Lugg May 21 '15 at 17:37
  • 4
    It should be set to a function doing nothing. The current StompJS version does not check if debug is set, it will just try to execute it. When setting debug to null, it will throw an error. – jpietzsch Sep 24 '19 at 12:07
53

I tried JR's answer but started receiving errors - changing debug to an empty function worked ...

stompClient.debug = () => {};
PaulB
  • 23,264
  • 14
  • 56
  • 75