Native messaging host not starting when opening Chrome

7.3k views Asked by At

I am trying to make a page-action extension that will communicate with a native messaging host (that is an EXE file).

I have installed my extension and I see its UI working as expected, but the EXE is not started. Do I need to do something myself to start it apart from that? :

port = chrome.runtime.connectNative(hostName);

I have installed the host in the registry like so:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.google.chrome.example.echo] @="C:\Users\me\Desktop\nativeMessaging\host\com.google.chrome.example.echo-win.json"

(I have also added this manually because there seemed to be a mess with the x86 and x64 bit version hives...)

Host Manifest file:

{
  "name": "com.google.chrome.example.echo",
  "description": "Chrome Native Messaging API Example Host",
  "path": "native-messaging-example-host.bat",
  "type": "stdio",
  "allowed_origins": [
    "chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/",
    "*"
  ]
}

Inside native-messaging-example-host.bat I have the :

MyExeName.exe

As you can see, I have added a "*" in allowed_origins JUST IN CASE the other option was not right for page actions.

I have also tried to put the EXE name directly inside the manifest file, but again with no luck.

I still get a :

Specified native messaging host not found. 

I also check with ProccessExplorer to see what apps Chrome loads, just in case it gets loaded, but I don't see it there either.

The weird things is that I have started modifying the native messaging host sample from Google and I think it was working as an app. It stopped working when I turned it into a page action extension.

Does anyone have any idea what is wrong here?

4

There are 4 answers

0
Scott Jeslis On BEST ANSWER

I had a similar issue. Enabling logging did not help. Turned out to be in my registry key:

[HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts

I had quotes around the EXE and path, e.g. "C:\Temp\Chrome\ChromeNativeApp.exe" vs. C:\Temp\Chrome\ChromeNativeApp.exe

0
C. Szabo On

I had a similar problem. And nothing here helped. What made the problem go away was changing the name of the host from "com.me.DbServer" to "com.me.test". This change made everything suddenly work. I guess that either DbServer is a reserved name or more likely that uppercase letters are not allowed. I am using Chrome 69.

0
AbsolutelyFreeWeb On

Aside from turning on logging, you can also take the approach of using procmon from sysinternals. It is like regmon and filemon in one, so you can follow chrome query the registry keys, then read the manifest, then run the executable and you can see where it goes wrong.

I had an issue previously, the exe would not run, and by doing the above, I found there was a small typo in the key, that I had missed.

For enabling logging, look at the following: https://www.chromium.org/for-testers/enable-logging e.g. you can start your browser with following command line arguments: --vmodule=extension_updater=2 --enable-logging

0
Roman Mishin On

I had similar problem: chrome was creating the port, but not starting the program. Tracing with Sysinternals procmon.exe I found that activity stalls with call to C:\Programs\TCCLE\tcc.exe. I use Take Command as cmd.exe replacement and environment variable ComSpec was set to C:\Programs\TCCLE\tcc.exe; I changed ComSpec back to C:\WINDOWS\system32\cmd.exe and the program started.