From a3b9727d64beea5aae8d8d7eb2c6e026318b37d8 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Wed, 7 Jul 2021 09:52:45 -0400 Subject: [PATCH] bugfix: selecting FS to handle createMessage api --- lib/routes/api/accounts.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/routes/api/accounts.js b/lib/routes/api/accounts.js index e5e2eb2..10d19de 100644 --- a/lib/routes/api/accounts.js +++ b/lib/routes/api/accounts.js @@ -642,7 +642,9 @@ router.post('/:sid/Messages', async(req, res) => { logger.info('No available feature servers to handle createMessage API request'); return res.json({msg: 'no available feature servers at this time'}).status(500); } - const ip = fs[idx++ % fs.length]; + let ip = fs[idx++ % fs.length]; + const arr = /^(.*):\d+$/.exec(ip); + if (arr) ip = arr[1]; logger.info({fs}, `feature servers available for createMessage API request, selecting ${ip}`); const serviceUrl = `http://${ip}:3000/v1/createMessage/${account_sid}`; await validateCreateMessage(logger, account_sid, req);