title: Chrome native message
body: <p>I am working on sample application of "<strong>Chrome Native Messaging</strong>". I did all the set as per steps mention on website. I am able to run application as well however i am not getting response message from native application. When i start extension very firts time i get the response message.</p>
  
  <p><a href="https://developer.chrome.com/extensions/examples/api/nativeMessaging/app.zip" rel="nofollow noreferrer">Downloaded sample from here</a> </p>
  
  <p>When i sent message from browser native app not responding it check below image</p>
  
  <p><img src="https://i.stack.imgur.com/iW3Sx.png" alt="enter image description here"></p>
  
  <p><strong>C# code as below</strong></p>
  
  <pre><code>static void Main(string[] args)
      {
          string message = "test message from native app.";
          OpenStandardStreamOut(message);
          while (OpenStandardStreamIn() != null || OpenStandardStreamIn() != "")
          {
              OpenStandardStreamOut("Received to Native App: " + OpenStandardStreamIn());
              OpenStandardStreamOut("Recieved: " + OpenStandardStreamIn());
          }
      }
  
      private static string OpenStandardStreamIn()
      {
          //// We need to read first 4 bytes for length information
          Stream stdin = Console.OpenStandardInput();
          int length = 0;
          byte[] bytes = new byte[4];
          stdin.Read(bytes, 0, 4);
          length = System.BitConverter.ToInt32(bytes, 0);
          string input = "";
          for (int i = 0; i &lt; length; i++)
          {
              input += (char)stdin.ReadByte();
          }
          return input;
      }
  
      private static void OpenStandardStreamOut(string stringData)
      {
          //// We need to send the 4 btyes of length information
          string msgdata = "{\"text\":\"" + stringData + "\"}";
          int DataLength = msgdata.Length;
          Stream stdout = Console.OpenStandardOutput();
          stdout.WriteByte((byte)((DataLength &gt;&gt; 0) &amp; 0xFF));
          stdout.WriteByte((byte)((DataLength &gt;&gt; 8) &amp; 0xFF));
          stdout.WriteByte((byte)((DataLength &gt;&gt; 16) &amp; 0xFF));
          stdout.WriteByte((byte)((DataLength &gt;&gt; 24) &amp; 0xFF));
          //Available total length : 4,294,967,295 ( FF FF FF FF )
          Console.Write(msgdata);
      }
  </code></pre>
  
  <p><code>manifest.json</code> as below</p>
  
  <pre><code>  {"name": "com.example.native",
    "description": "Native support for Chrome Extension",
    "path": "NativeApp.exe",
    "type": "stdio",
    "allowed_origins": [
      "chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/"
    ],
    "permissions": [
      "nativeMessaging"
    ]
  }
  </code></pre>
  
  <p>Some where i feel we are not receiving response from native host becoz i have added debug point to following code in browser which is not getting hit</p>
  
  <pre><code>function onNativeMessage(message) {
  </code></pre>
  
  <p>appendMessage("Received message: <b>" + JSON.stringify(message) + "</b>");
  }</p>
  
  <p>Am i missing something ?</p>