私のデータベースには2000人以上のユーザーがいますが、すべてのユーザーにメッセージをブロードキャストしようとすると約200リクエストを送信してサーバーが停止し、エラー以下のように:Node.jsからAPIに多くのリクエストを送信するとエラーが発生する
function callSendAPI(messageData) {
request({
uri: 'https://graph.facebook.com/v2.6/me/messages',
qs: { access_token: '#####' },
method: 'POST',
json: messageData
}, function (error, response, body) {
if (!error && response.statusCode == 200) {
var recipientId = body.recipient_id;
var messageId = body.message_id;
if (messageId) {
console.log("Successfully sent message with id %s to recipient %s",
messageId, recipientId);
} else {
console.log("Successfully called Send API for recipient %s",
recipientId);
}
} else {
console.error("Failed calling Send API");
console.log(error)
}
});
}
:これは私の要求である
Error!: Error: socket hang up
:たまに
{ Error: connect ETIMEDOUT 31.13.88.4:443
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
code: 'ETIMEDOUT',
errno: 'ETIMEDOUT',
syscall: 'connect,
address: '31.13.88.4',
port: 443 }
私は言い、別のエラーが出ます
私はしばらくの間、待機を呼び出すAPIを作るために
setTimeout
を試してみました:彼/彼女は、同様のエラーに直面した場合
setTimeout(function(){callSendAPI(data)},200);
誰でも助けることができますか?
私は送信APIへの呼び出しの高いレートをサポートし、それが200回のコールと限定されるものではなく、メッセンジャープラットフォームを使用してい
編集しました。
最初にエラーをGoogleで検索してください。https://www.google.com/search?q=ETIMEDOUT+node.js – mplungjan
@mplungjan私はしましたが、http.requestに関連する回答は見つかりませんでした –
q = ETIMEDOUT + node.js + POST + facebook – mplungjan