2017-11-13 30 views
3

私はcreate hookを私のAuth0 Delegated Administration Extensionに使っています。ETIMEDOUT Node.jsに接続

トリガーフックを作成するときに、私はこのエラーを取得しています:

Error: connect ETIMEDOUT xxx.xxx.xxx.xxx:8081 
    at Object.exports._errnoException (util.js:1020:11) 
    at exports._exceptionWithHostPort (util.js:1043:20) 
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14) 

は、フック関数を作成しては次のとおりです。

function(ctx, callback) { 

    var request = require('request'); 

    // Perform any asynchronous actions 
    var API_URL = "https://example.com:8081/api/saveData"; 

    var empFirstName = 'Jhone'; 
    var empId = '123'; 

    request.post({ 
      url: API_URL, 
      json: { 
       firstName: empFirstName, 
       userId: empId 
      } 
     }, 
     function(error, response, body) { 
      if (error) { 
       ctx.log('Create failed to '+API_URL+':', error); 
       return callback(new Error('Something went wrong. Please try again.')); 
      } 
      ctx.log('Create successful! Server responded with:', body); 
      return callback(null, { 
       /*some data here*/ 
      }); 
     }); 
} 

私はpostmanで試してみましたし、期待どおりに動作します。しかし、フックを作成すると、私は上記のエラーになっています。

何が問題になりますか?

+0

あなたのコールバックの外観は? –

+0

郵便配達員を使用して、それが応答しているかどうかを確認してください。 –

+0

@SelloMkantjwaこれはサーバーにも当てはまりません。エンドポイントにコンソールログを追加しましたが、決して印刷されません。 @ NidhinDavidええ、 – Bishan

答えて

0

エンドポイントが利用できない、または応答していないようです。

このエンドポイントがcontent-typeを処理することを確認してください:application/json?それ以外の場合は、x-form-www-urlencodedとして送信してください。

request.post({ 
    url: MY_URL, 
    form: { 
     firstName: empFirstName, 
     userId: empId 
    } 
+0

これも運がありません – Bishan

関連する問題