I'm using Chrome's native messaging API to connect to a native host I'm developing in Go with the Cobra library. The native application has a standalone CLI (implemented with Cobra), and the bare command (without any arguments) starts listening for JSON via stdin, which is meant to be an API for Chrome to interact with.
However, it fails every time the extension makes requests to the native messaging host (the client just immediately disconnects from the process). When I start Chrome with the --enable-logging flag I can see that the native host is erroring with unknown command "chrome-extension://cnjopnegooahjdngnkhiokognkdjiioc/" for "--native-app-name--". This is Cobra's error message that means "chrome-extension://cnjopnegooahjdngnkhiokognkdjiioc/" is being used as an argument, which seems to mean that Chrome is invoking the native host with app-name chrome-extension://cnjopnegooahjdngnkhiokognkdjiioc/ instead of just app-name.
Here's the code I'm using from the extension to call the native host:
var port = chrome.runtime.connectNative('app-name');
port.onMessage.addListener(function(msg) {
console.log(msg);
});
port.onDisconnect.addListener(function() {
console.log("disconnected");
});
port.postMessage({cmd:"ping"});
I can't find any documentation that suggests that Chrome sends the extension address as an argument, or whether it can be prevented.