Can not connect to node.js inspector using WebSocket












0














I am trying to develop a node.js debugger in JavaScript. I am executing a JS script using node --inspect-brk like below-



c:nodenode --inspect-brk test.js


Then it prints the WebSocket URL-



Debugger listening on ws://127.0.0.1:9229/bb6eed9d-19d4-47ae-99cf-2f2a09e125ef
For help see https://nodejs.org/en/docs/inspector


Now I am using WebSocket to connect-



var ws = new WebSocket("ws://127.0.0.1:9229/bb6eed9d-19d4-47ae-99cf-2f2a09e125ef");
ws.onmessage = function(data){console.log(data);}
ws.onerror = function(data){console.log(data);}


But, when I send the continue command then I get no response from V8-



ws.send(JSON.stringify({"seq":117,"type":"request","command":"continue"}));


I found the command for V8 protocol here - https://github.com/buggerjs/bugger-v8-client/blob/master/PROTOCOL.md



In fact ws.readyState is 1, that means connection got established properly. There is no error or message logged. Even in chrome network tab I can see data sent but there is no data received from V8, see screenshot.



Network log



Test JS code-



var x=1;
x++;
console.log(x);









share|improve this question





























    0














    I am trying to develop a node.js debugger in JavaScript. I am executing a JS script using node --inspect-brk like below-



    c:nodenode --inspect-brk test.js


    Then it prints the WebSocket URL-



    Debugger listening on ws://127.0.0.1:9229/bb6eed9d-19d4-47ae-99cf-2f2a09e125ef
    For help see https://nodejs.org/en/docs/inspector


    Now I am using WebSocket to connect-



    var ws = new WebSocket("ws://127.0.0.1:9229/bb6eed9d-19d4-47ae-99cf-2f2a09e125ef");
    ws.onmessage = function(data){console.log(data);}
    ws.onerror = function(data){console.log(data);}


    But, when I send the continue command then I get no response from V8-



    ws.send(JSON.stringify({"seq":117,"type":"request","command":"continue"}));


    I found the command for V8 protocol here - https://github.com/buggerjs/bugger-v8-client/blob/master/PROTOCOL.md



    In fact ws.readyState is 1, that means connection got established properly. There is no error or message logged. Even in chrome network tab I can see data sent but there is no data received from V8, see screenshot.



    Network log



    Test JS code-



    var x=1;
    x++;
    console.log(x);









    share|improve this question



























      0












      0








      0


      1





      I am trying to develop a node.js debugger in JavaScript. I am executing a JS script using node --inspect-brk like below-



      c:nodenode --inspect-brk test.js


      Then it prints the WebSocket URL-



      Debugger listening on ws://127.0.0.1:9229/bb6eed9d-19d4-47ae-99cf-2f2a09e125ef
      For help see https://nodejs.org/en/docs/inspector


      Now I am using WebSocket to connect-



      var ws = new WebSocket("ws://127.0.0.1:9229/bb6eed9d-19d4-47ae-99cf-2f2a09e125ef");
      ws.onmessage = function(data){console.log(data);}
      ws.onerror = function(data){console.log(data);}


      But, when I send the continue command then I get no response from V8-



      ws.send(JSON.stringify({"seq":117,"type":"request","command":"continue"}));


      I found the command for V8 protocol here - https://github.com/buggerjs/bugger-v8-client/blob/master/PROTOCOL.md



      In fact ws.readyState is 1, that means connection got established properly. There is no error or message logged. Even in chrome network tab I can see data sent but there is no data received from V8, see screenshot.



      Network log



      Test JS code-



      var x=1;
      x++;
      console.log(x);









      share|improve this question















      I am trying to develop a node.js debugger in JavaScript. I am executing a JS script using node --inspect-brk like below-



      c:nodenode --inspect-brk test.js


      Then it prints the WebSocket URL-



      Debugger listening on ws://127.0.0.1:9229/bb6eed9d-19d4-47ae-99cf-2f2a09e125ef
      For help see https://nodejs.org/en/docs/inspector


      Now I am using WebSocket to connect-



      var ws = new WebSocket("ws://127.0.0.1:9229/bb6eed9d-19d4-47ae-99cf-2f2a09e125ef");
      ws.onmessage = function(data){console.log(data);}
      ws.onerror = function(data){console.log(data);}


      But, when I send the continue command then I get no response from V8-



      ws.send(JSON.stringify({"seq":117,"type":"request","command":"continue"}));


      I found the command for V8 protocol here - https://github.com/buggerjs/bugger-v8-client/blob/master/PROTOCOL.md



      In fact ws.readyState is 1, that means connection got established properly. There is no error or message logged. Even in chrome network tab I can see data sent but there is no data received from V8, see screenshot.



      Network log



      Test JS code-



      var x=1;
      x++;
      console.log(x);






      node.js v8 node-inspector






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 15 '18 at 11:19







      saurav

















      asked May 10 '18 at 11:51









      sauravsaurav

      537618




      537618
























          1 Answer
          1






          active

          oldest

          votes


















          1














          try to send this message: {"id": 7, "method": "Runtime.runIfWaitingForDebugger"};



          i think that maybe the problem is the parameter "-brk" blocks the nodejs process. so when you send message, it can not get response. but when you open chrome to debug it at that time, you found it works well. so, open the chrome devtool and check the ws network info. i found ws sends some messages when it builds. maybe when you send message: "Runtime.runIfWaitingForDebugger", the nodejs process will continue running.



          shell.js



          ws network






          share|improve this answer



















          • 3




            Could you elaborate a bit on the solution you are providing? Why would that work?
            – Urosh T.
            Nov 23 '18 at 7:41










          • Really helpful answer. Thanks a lot.
            – saurav
            Nov 24 '18 at 16:05











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50272317%2fcan-not-connect-to-node-js-inspector-using-websocket%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          try to send this message: {"id": 7, "method": "Runtime.runIfWaitingForDebugger"};



          i think that maybe the problem is the parameter "-brk" blocks the nodejs process. so when you send message, it can not get response. but when you open chrome to debug it at that time, you found it works well. so, open the chrome devtool and check the ws network info. i found ws sends some messages when it builds. maybe when you send message: "Runtime.runIfWaitingForDebugger", the nodejs process will continue running.



          shell.js



          ws network






          share|improve this answer



















          • 3




            Could you elaborate a bit on the solution you are providing? Why would that work?
            – Urosh T.
            Nov 23 '18 at 7:41










          • Really helpful answer. Thanks a lot.
            – saurav
            Nov 24 '18 at 16:05
















          1














          try to send this message: {"id": 7, "method": "Runtime.runIfWaitingForDebugger"};



          i think that maybe the problem is the parameter "-brk" blocks the nodejs process. so when you send message, it can not get response. but when you open chrome to debug it at that time, you found it works well. so, open the chrome devtool and check the ws network info. i found ws sends some messages when it builds. maybe when you send message: "Runtime.runIfWaitingForDebugger", the nodejs process will continue running.



          shell.js



          ws network






          share|improve this answer



















          • 3




            Could you elaborate a bit on the solution you are providing? Why would that work?
            – Urosh T.
            Nov 23 '18 at 7:41










          • Really helpful answer. Thanks a lot.
            – saurav
            Nov 24 '18 at 16:05














          1












          1








          1






          try to send this message: {"id": 7, "method": "Runtime.runIfWaitingForDebugger"};



          i think that maybe the problem is the parameter "-brk" blocks the nodejs process. so when you send message, it can not get response. but when you open chrome to debug it at that time, you found it works well. so, open the chrome devtool and check the ws network info. i found ws sends some messages when it builds. maybe when you send message: "Runtime.runIfWaitingForDebugger", the nodejs process will continue running.



          shell.js



          ws network






          share|improve this answer














          try to send this message: {"id": 7, "method": "Runtime.runIfWaitingForDebugger"};



          i think that maybe the problem is the parameter "-brk" blocks the nodejs process. so when you send message, it can not get response. but when you open chrome to debug it at that time, you found it works well. so, open the chrome devtool and check the ws network info. i found ws sends some messages when it builds. maybe when you send message: "Runtime.runIfWaitingForDebugger", the nodejs process will continue running.



          shell.js



          ws network







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 23 '18 at 11:02

























          answered Nov 23 '18 at 7:37









          rainrain

          262




          262








          • 3




            Could you elaborate a bit on the solution you are providing? Why would that work?
            – Urosh T.
            Nov 23 '18 at 7:41










          • Really helpful answer. Thanks a lot.
            – saurav
            Nov 24 '18 at 16:05














          • 3




            Could you elaborate a bit on the solution you are providing? Why would that work?
            – Urosh T.
            Nov 23 '18 at 7:41










          • Really helpful answer. Thanks a lot.
            – saurav
            Nov 24 '18 at 16:05








          3




          3




          Could you elaborate a bit on the solution you are providing? Why would that work?
          – Urosh T.
          Nov 23 '18 at 7:41




          Could you elaborate a bit on the solution you are providing? Why would that work?
          – Urosh T.
          Nov 23 '18 at 7:41












          Really helpful answer. Thanks a lot.
          – saurav
          Nov 24 '18 at 16:05




          Really helpful answer. Thanks a lot.
          – saurav
          Nov 24 '18 at 16:05


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50272317%2fcan-not-connect-to-node-js-inspector-using-websocket%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Berounka

          Sphinx de Gizeh

          Different font size/position of beamer's navigation symbols template's content depending on regular/plain...