Proxy経由でWatson Assistantに接続する方法(JavaScript)
3071 ワード
はじめに
アプリケーションからProxy経由でWatson Assistantに繋ぎたい。
本来はAssistantサービスのインスタンス化時にProxyの設定を入れれば可能らしいが、うまくいかない。
どうもSDKのバグのようで、現在fix申請中だが、SDKを修正することで解決したのでその方法について記載する。
環境
Watson Assistant V1 2019-02-28
Node.js 12.5.0
tunnelのinstall
npm install tunnel
SDKの修正
npm install tunnel
npm install ibm-watsonするとインストールされるnode_modules/ibm-cloud-sdk-core/lib/requestwrapper.jsに以下のコードを追加する。
先頭に
requestwrapper.js
var tunnel = require("tunnel");
axios_1.default.createに
requestwrapper.js
var agent = tunnel.httpsOverHttp({
proxy: {
host: 'XXX.XXX.XXX.XXX',
port: YYYY,
},
});
axiosConfig.httpsAgent = agent;
axiosConfig.proxy = false;
this.axiosInstance = axios_1.default.create(axiosConfig);
参考情報
createSession from Assistant V2 is not working behind http proxy
IBM Cloud API Docs Watson Assistant v1
Author And Source
この問題について(Proxy経由でWatson Assistantに接続する方法(JavaScript)), 我々は、より多くの情報をここで見つけました https://qiita.com/S-hiyuko/items/c8220c96c2992b0f6de3著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .