【发布时间】:2020-04-19 23:00:37
【问题描述】:
我一直在尝试使用 Chrome 原生消息 API 在 Chrome 扩展程序和应用程序之间进行通信。我已经完全按照DeveloperChrome Website 中提到的步骤/说明进行操作。从NativeMessaging Examples 下载示例本机消息传递应用程序后,通过运行install_host.sh 完成其设置。当我在演示应用程序中单击连接按钮时,它失败并出现错误:
Failed to connect: Native host has exited.
除此之外,我通过使用命令启用其日志,以调试模式从终端运行 Chrome 实例
open /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
--args --enable-logging --v=1
我发现权限出了点问题。访问文件的权限是Read&Write 所有人。此问题与 MacOS 相关,因为同一示例在 Windows 上运行良好。
以下是 Chrome 错误日志:
/usr/local/Cellar/python@2/2.7.17_1/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: 无法打开文件 '/Users/XXX/Desktop/host/native-messaging-example-host': [Errno 1] 不允许操作
【问题讨论】:
标签: macos file-permissions chrome-native-messaging