Chrome应用无法与Windows上的本机主机通信 [英] Chrome App fails to communicate with native host on windows

查看:86
本文介绍了Chrome应用无法与Windows上的本机主机通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Java编写了chrome应用程序和本机消息传递主机.该组合在Linux上可以正常工作.但是,当我尝试将组合端口移植到Windows时,无法建立通信.包含主机的jar与linux变体完全相同.我正在使用以下脚本(start.bat)启动Java主机:

I have written a chrome app and a native messaging host in Java. The combo works fine on linux. However when I try to port the combo to windows the communication can not be established. The jar where the host is contained is exactly the same as the linux variant. I am using the following script (start.bat) to start the Java host:

@echo off
java -jar "%~dp0theHost.jar"

json清单如下:

{
   "name": "com.service.host",
   "description": "Native messaging host",
   "path": "start.bat",
   "type": "stdio",
   "allowed_origins": [
      "chrome-extension://--the ID--/" 
   ]
}

我已将HKEY_LOCAL_MACHINE \ SOFTWARE \ Google \ Chrome \ NativeMessagingHosts \ com.service.host配置为路径e:\ hosts \ com.service.host.jsonservice.bat文件和jar(theHost.jar)也在e:\ hosts \目录中.尝试开始通信时,出现错误:与本机消息传递主机通信时出错.我还尝试将清单中的路径更改为: e:\\ hosts \\ start.bat 但结果/错误是相同的.当我在cmd窗口中手动启动bat文件时,主机会据我所知正确初始化,然后等待Chrome应用发出的消息.另外,当我添加以下行时:

I have configured the HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.service.host to the path e:\hosts\com.service.host.json the service.bat file together with the jar (theHost.jar) is also in the e:\hosts\ directory. When trying to start the communication I get the error: Error when communicating with the native messaging host. I also tried to change the path in the manifest to: e:\\hosts\\start.bat but the result/error is the same. When I start the bat file manually in the cmd window the host initializes properly as far as I can tell and waits for the message from the Chrome app. Also, when I added the line:

copy NUL empty.txt

在调用bat时创建一个空文件的"java-jar ..."行之前,该空文件是在手动启动bat时创建的,而不是在chrome应用程序调用"时创建的.任何帮助将不胜感激.

before the "java - jar..." line to create an empty file when the bat is invoked, the empty file is created when the bat is started manually and is not created when "invoked" by the chrome app. Any help would be greatly appreciated.

版本:Windows 7,Java 7u55,Chrome 34.0.1847.116 m

Versions: Windows 7, Java 7u55, Chrome 34.0.1847.116 m

推荐答案

要调试在JS上下文中未给出有意义消息的错误,您可以尝试使用

To debug errors that do not give meaningful messages in JS context, you can try using Chrome logging; this can give more information (which helped in your case).

这篇关于Chrome应用无法与Windows上的本机主机通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆