hubot pug me で Proxy エラー
社内環境等、インターネットと Hubot の間に Proxy を挟んだ環境では、 Proxy を設定しないと Socket Error が発生してしまいます。
proxy を設定しないと・・・
Proxy を設定しないと下記のようなエラーが発生してしまいます。
Hubot> hubot pug me Hubot> [Tue Feb 10 2015 16:02:12 GMT+0900 (東京 (標準時))] ERROR TypeError: Cannot read property 'pug' of null at C:\hubotwork\hogebot\node_modules\hubot-pugme\src\pugme.coffee:19:34 at ClientRequest.<anonymous> (C:\hubotwork\hogebot\node_modules\hubot\node_modules\scoped-http-client\src\index.js:87 :20) at ClientRequest.emit (events.js:95:17) at Socket.socketErrorListener (http.js:1552:9) at Socket.emit (events.js:95:17) at net.js:441:14 at process._tickCallback (node.js:442:13) [Tue Feb 10 2015 16:02:12 GMT+0900 (東京 (標準時))] ERROR TypeError: Cannot read property 'pug' of null at C:\hubotwork\hogebot\node_modules\hubot-pugme\src\pugme.coffee:19:34 at ClientRequest.<anonymous> (C:\hubotwork\hogebot\node_modules\hubot\node_modules\scoped-http-client\src\index.js:87 :20) at ClientRequest.emit (events.js:95:17) at Socket.socketCloseListener (http.js:1527:9) at Socket.emit (events.js:117:20) at TCP.close (net.js:466:12)
Proxy の設定方法
現在、Hubot には Proxy の設定方法がありません。そこで、Hubot 内で使われている scoped-http-client に直接 Proxy を設定してやります。
編集するのは次のscoped-http-client の index.js ファイルです。
hogebot\node_modules\hubot\node_modules\scoped-http-client\src index.js
編集前に戻せるようにバックアップを取っておいてください。38行目前後の下記のコードを修正します。コメントアウトしてあるのが元のコードです。
port = this.options.port || ScopedClient.defaultPort[this.options.protocol] || 80; requestOptions = { //port: port, port: [YOUR PROXY PORT], //host: this.options.hostname, host: [YOUR PROXY HOST], method: method, //path: this.fullPath(), // ↓[EDIT THIS PATH]↓ path: 'http://' + this.options.hostname + this.fullPath(), headers: headers, //agent: this.options.agent // ↓[EDIT THIS AGENT]↓ agent: this.options.agent || false };
pug me!!
修正が終わったら、pug me しましょう!
Hubot> Hubot> Hubot> Hubot> hubot pug me
Hubot>