【发布时间】:2018-03-15 13:46:54
【问题描述】:
在带有 Ubuntu 16.04 的 Vagrant VM 中工作...
我之前能够使用 Google 的 Dialogflow API 检测意图,但现在它在我的新 VM 中引发错误。
步骤:
- 创建 Dialogflow 项目
- 下载应用程序凭据 JSON
npm i dialogflow-
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/creds.jsonnode -e ' const dialogflow = require("dialogflow"); const cli = new dialogflow.SessionsClient(); const session = cli.sessionPath("df-project-id", "session-id"); const request = { session, queryInput: { text: { text: "Hello" } } }; cli.detectIntent(request).then(console.log, console.error);'
错误:
Auth error:Error: write EPROTO 140436597872448:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:827
调试:
证书位于默认位置 /etc/ssl/certs/ca-certificates.crt,我知道 NodeJS 正在使用它们,因为 NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt ${df test above} 说:
(node:4067) Warning: Ignoring extra certs from '/etc/ssl/certs/ca-certificates.crt', load failed: error:0B07C065:x509 certificate routines:X509_STORE_add_cert:cert already in hash table
我看到请求也使用了环境变量中声明的认证代理:
http_proxy=http://user:pass@proxy:port
HTTP_PROXY=http://user:pass@proxy:port
https_proxy=http://user:pass@proxy:port
HTTPS_PROXY=http://user:pass@proxy:port
请求:
{
"pathname": "https://www.googleapis.com/oauth2/v4/token",
"nativeProtocols": {
"http:": {
"METHODS": [...],
"STATUS_CODES": {...},
"globalAgent": {
"domain": {
"domain": null,
"_events": {},
"_eventsCount": 1,
"members": []
},
"_events": {},
"_eventsCount": 1,
"defaultPort": 80,
"protocol": "http:",
"options": {
"path": null
},
"requests": {},
"sockets": {},
"freeSockets": {},
"keepAliveMsecs": 1000,
"keepAlive": false,
"maxSockets": null,
"maxFreeSockets": 256
}
},
"https:": {
"globalAgent": {
"domain": {
"domain": null,
"_events": {},
"_eventsCount": 1,
"members": []
},
"_events": {},
"_eventsCount": 1,
"defaultPort": 443,
"protocol": "https:",
"options": {
"path": null
},
"requests": {},
"sockets": {},
"freeSockets": {},
"keepAliveMsecs": 1000,
"keepAlive": false,
"maxSockets": null,
"maxFreeSockets": 256,
"maxCachedSessions": 100,
"_sessionCache": {
"map": {},
"list": []
}
}
}
},
"host": "proxy.*.com",
"port": "8080",
"hostname": "proxy.*.com",
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "axios/0.18.0",
"Content-Length": 734,
"host": "www.googleapis.com",
"Proxy-Authorization": "Basic *hash*"
},
"method": "post",
"path": "https://www.googleapis.com/oauth2/v4/token",
"maxBodyLength": 10485760,
"maxRedirects": 21,
"protocol": "https:",
"_defaultAgent": {
"domain": {
"domain": null,
"_events": {},
"_eventsCount": 1,
"members": []
},
"_events": {},
"_eventsCount": 1,
"defaultPort": 443,
"protocol": "https:",
"options": {
"path": null
},
"requests": {},
"sockets": {},
"freeSockets": {},
"keepAliveMsecs": 1000,
"keepAlive": false,
"maxSockets": null,
"maxFreeSockets": 256,
"maxCachedSessions": 100,
"_sessionCache": {
"map": {},
"list": []
}
}
}
【问题讨论】:
-
我想这可能会对你有所帮助stackoverflow.com/questions/20719092/…
-
感谢您的建议。如果我使用
https包,这可能会起作用,但 DF 客户端使用grpc
标签: node.js ssl proxy dialogflow-es