title: Google Chrome Extension - Specified Native Messaging Host Not Found
body: <p>I created an extension that uses native messaging to a host.</p>
  
  <p>The manifest.json of the extension is:</p>
  
  <pre><code>{
      "manifest_version": 2,
      "version": "1.0",
      "name": "Native Messaging Example",
      "description": "Send a message to a native application",
      "permissions": [
          "nativeMessaging"
      ],
      "browser_action": {
          "default_popup": "popup.html"
      }
  }
  </code></pre>
  
  <p>The popup.html:</p>
  
  <pre><code>    &lt;html&gt;
          &lt;head&gt;
              &lt;script src="./main.js"&gt;&lt;/script&gt;
          &lt;/head&gt;
          &lt;body&gt;
              &lt;button id="buttonToPress"&gt;Press&lt;/button&gt;
          &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>The main.js file:</p>
  
  <pre><code>    var port = null;
  
      function connect() {
  
          port = chrome.runtime.connectNative('com.google.chrome.example.echo');
  
          port.onMessage.addListener(function(message) {
  
              alert(message);
  
              port.disconnect();
          });
  
          port.onDisconnect.addListener(function() {
  
              port = null;
  
              alert(chrome.runtime.lastError.message);
          });
  
          var message = {
              'filePath': 'C:\\Users\\username\\Desktop\\themes\\Wallpaper\\Architecture\\img13.jpg'
          };
  
          port.postMessage(message);
      }
  
      document.addEventListener('DOMContentLoaded', function() {
          document.getElementById('buttonToPress').addEventListener('click', connect);
      });
  </code></pre>
  
  <p>I have a native application <code>abc.exe</code>.</p>
  
  <p>The native application manifest.json:</p>
  
  <pre><code>    {
          "name": "com.google.chrome.example.echo",
          "description": "Chrome Native Messaging API Example Host",
          "path": "./abc.exe",
          "type": "stdio",
          "allowed_origins": [
              "chrome-extensions://fegpbklgdffjmfjmhknpmgepbddbcghk/"
          ]
      }
  </code></pre>
  
  <p>In the registrey, The <strong>Default Value</strong> of <code>HKEY_CURRENT_USER\Software\Google\Chrome\NativeMessagingHosts\com.google.chrome.example.echo</code> is <code>C:\Users\username\Desktop\Extension1\NativeApp\manifest.json</code> (This is where the manifest file is physically exists).</p>
  
  <p>The problem is, that each time i run it, it keep saying: <strong>'Specified Native Messaging Host Not Found'</strong>... I rechecked my code and it seems to be fine, just like the google's guide of native messaging. The error that logged in the debugger's console is: <strong>'Uncaught Error: Attempting to use a disconnected port object'</strong>, which i don't know why it keeps happening.</p>
  
  <p>Also, after the <code>chrome.runtime.connectNative</code>, the .exe doesn't start (after seeing in the task manager), and it just seems likes there something that not code-related, but more likely to be in the configuration.</p>
  
  <p>I need some help in figuring it out, so any help would be usefull!</p>
  
  <p>Thanks</p>