LoginSignup
0
1

More than 3 years have passed since last update.

Proxy経由でWatson Assistantに接続する方法(JavaScript)

Posted at

はじめに

アプリケーションから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 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

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1