Error Connecting to Native App

1,675 views
Skip to first unread message

Michael

unread,
Dec 4, 2013, 2:10:08 AM12/4/13
to chromium-...@chromium.org
Hi all,

I'm trying to develop an extension that connects to a native app, but when I go to the console for my extension's background page and try to connect, I get an error.

var port=chrome.runtime.connectNative("app.Chrome-AHK")
Error: Error connecting to native app: app.Chrome-AHK

Here is the manifest of my native app
------------------------------------
{
"app": "app.Chrome-AHK",
"description": "Give AutoHotkey scripts access to the Chrome extensions API.",
"path": "Chrome-AHK.exe",
"type": "stdio",
"allowed_origins": [
"chrome-extension://khioaaahafcipobnljdodicofgbhbbee/"
]
}
----------------------------------

and here is the registry file that I added to register the native app.
-----------------------------------
[HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\app.Chrome-AHK]
@="E:\\Dropbox\\Chrome-AHK\\Native_App\\manifest.json"
-----------------------------------

The executable that is to be run is a compiled AutoHotkey script that simply show a message box to let me know that it's running.

Mihai Coman

unread,
Dec 4, 2013, 4:06:04 AM12/4/13
to chromium-...@chromium.org
Try changing the reg value to @="E:\\\\Dropbox\\\\Chrome-AHK\\\\Native_App\\\\manifest.json". Don't ask...it worked this way in my case.

2nd: relative paths "should" work but it doesn't hurt to try using absolute paths (for testing, at least) in your manifest:

{
"app": "app.Chrome-AHK",
"description": "Give AutoHotkey scripts access to the Chrome extensions API.",
"path": "E:\\Dropbox\\Chrome-AHK\\Native_App\\Chrome-AHK.exe",
"type": "stdio",
"allowed_origins": [
"chrome-extension://khioaaahafcipobnljdodicofgbhbbee/"
]
}

yup, just "\\" this time.

Good luck!

Michael

unread,
Dec 4, 2013, 11:34:42 PM12/4/13
to chromium-...@chromium.org
Hi,

Thanks for helping me out with this.

Unfortunately, that has not helped.

Here is a link to download a backup of the entire directory.

The scripts folder just contains two empty scripts, I did not create any content yet, i was planning to do that after I had established two-way communication between the native app and the extension.

Mihai Coman

unread,
Dec 5, 2013, 5:01:29 AM12/5/13
to chromium-...@chromium.org
Are you sure that your extension is loaded with the same id as the one you specified in the native app's manifest? "chrome-extension://khioaaahafcipobnljdodicofgbhbbee/"

If your background page is empty, who's doing var port=chrome.runtime.connectNative("app.Chrome-AHK")? You should at least add that to your background page.

Michael Tepfer

unread,
Dec 5, 2013, 11:49:33 AM12/5/13
to Mihai Coman, chromium-...@chromium.org
The manifest does have the correct chrome extension ID, I triple-checked.

I was running that line of code in the console, I just tried putting it in the script and I got this message in the console;
Uncaught Error: Error connecting to native app: app.Chrome-AHK


--
You received this message because you are subscribed to a topic in the Google Groups "Chromium-extensions" group.
To unsubscribe from this topic, visit https://groups.google.com/a/chromium.org/d/topic/chromium-extensions/0tpZnA0qezY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/36e796a0-c224-49c9-9d3f-777cebaac4c3%40chromium.org.

Mihai Coman

unread,
Dec 6, 2013, 2:14:06 AM12/6/13
to chromium-...@chromium.org, Mihai Coman
Pay attention to the docs - I didn't:
- application manifest doesn't have an "app" key; it's called "name"
- the error you're getting is caused by the fact that the extension must have "nativeMessaging" listed in it's permissions

Those two aside, Chrome still seems to hate upper cased names. app.Chrome-AHK didn't work for me but app.chrome_ahk did.

App's manifest - manifest.json (you might want to consider changing it's name to something more sensible)
{
    "name": "app.chrome_ahk",

    "description": "Give AutoHotkey scripts access to the Chrome extensions API.",
    "path": "c:\\windows\\system32\\calc.exe",
    "type": "stdio",
    "allowed_origins": ["chrome-extension://fbihcjeglbockilpidhcilhlgdphmbbb/"]
}

In extension manifest, make sure the permissions are:
    "permissions": [
                    "nativeMessaging",
                    "tabs",
                    "activeTab",
                    "background",
                    "http://*/", "https://*/"
                    ],

background.js:
var port=chrome.runtime.connectNative("app.chrome_ahk");

registry:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Google\Chrome\NativeMessagingHosts\app.chrome_ahk]
@="S:\\\\tmp\\\\Chrome-AHK.bak\\\\Native_App\\\\manifest.json"
To unsubscribe from this group and all its topics, send an email to chromium-extensions+unsub...@chromium.org.

To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.

Michael Tepfer

unread,
Dec 8, 2013, 5:27:50 PM12/8/13
to Mihai Coman, chromium-...@chromium.org
Hi,
Thakn you again for helping me.
I made the changes you suggested and now there is no error when I call the connectNative() function.
However, the native app does not run.

Here is the link again.



To unsubscribe from this group and all its topics, send an email to chromium-extens...@chromium.org.

To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.

Mihai Coman

unread,
Dec 9, 2013, 3:32:22 AM12/9/13
to chromium-...@chromium.org, Mihai Coman
var port=chrome.runtime.connectNative("app.Chrome-AHK")

try lowercase maybe?
To unsubscribe from this group and all its topics, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.

--
You received this message because you are subscribed to a topic in the Google Groups "Chromium-extensions" group.
To unsubscribe from this topic, visit https://groups.google.com/a/chromium.org/d/topic/chromium-extensions/0tpZnA0qezY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.

Michael Tepfer

unread,
Dec 9, 2013, 5:45:18 AM12/9/13
to Mihai Coman, chromium-...@chromium.org
no luck.


To unsubscribe from this group and all its topics, send an email to chromium-extens...@chromium.org.

To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.

Mihai Coman

unread,
Dec 9, 2013, 6:27:15 AM12/9/13
to chromium-...@chromium.org, Mihai Coman
this one works for me: http://www.filedropper.com/chrome-ahkbak

If it still doesn't work, you're obviously doing something wrong (otherwise a lot more people would be around here complaining about the same kind of issues): I'd start from scratch - read the docs again, make a new extension in another folder, repeat all the steps, make sure you don't skip anything.
no luck.


--
You received this message because you are subscribed to a topic in the Google Groups "Chromium-extensions" group.
To unsubscribe from this topic, visit https://groups.google.com/a/chromium.org/d/topic/chromium-extensions/0tpZnA0qezY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.

Michael Tepfer

unread,
Dec 12, 2013, 11:17:35 AM12/12/13
to Mihai Coman, chromium-...@chromium.org
I think I know why it's not working as expected.

Chrome expects the native app to use stdio and my app does not do that so when chrome sends an input and does not get a response, it closes the port.

Thank you for helping me!


To unsubscribe from this group and all its topics, send an email to chromium-extens...@chromium.org.

To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
Reply all
Reply to author
Forward
0 new messages