Files
sbc-sip-sidecar/lib/config.js
T
Dave HortonandClaude Opus 5.5 f5c675952a feat: per-SBC registration Call-ID, and hand off the regbot role on AWS scale-in (#156)
The Call-ID of outbound registrations was the sip_gateway_sid, the same on
every SBC. When the regbot role moved to the other SBC, the registrar saw a
refresh of an existing binding from a different source address and Contact.
Some registrars 200 such a refresh without updating their routing, so inbound
calls to the registered trunk fail with 404 until the binding is recreated.
The Call-ID is now sip_gateway_sid@<sending SBC public IP>: stable across
refreshes and restarts of one SBC, new when the role moves, so a move looks
like a new registration. register_status also records the sending SBC as
sbcAddress.

With AWS_LIFECYCLE_DRAIN enabled the sidecar polls IMDS
autoscaling/target-lifecycle-state (the signal inbound drains on; detection
only, inbound completes the lifecycle hook). When the instance is being scaled
in, the regbot holder releases the lease while still running instead of after
the instance is gone; until now the draining SBC kept the registrations, so
carriers kept sending registration-trunk calls to an SBC that answers new
INVITEs with 503. It never claims the role back. Once another SBC has claimed
it, the draining SBC un-REGISTERs (Expires: 0) the bindings whose Contact
carries its own IP. Bindings with an AoR or realm Contact are left alone: the
new SBC sends the same Contact, and its REGISTER has already replaced ours.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 13:33:36 -04:00

98 lines
4.4 KiB
JavaScript

/* MYSQL */
const JAMBONES_MYSQL_HOST = process.env.JAMBONES_MYSQL_HOST;
const JAMBONES_MYSQL_USER = process.env.JAMBONES_MYSQL_USER;
const JAMBONES_MYSQL_PORT = process.env.JAMBONES_MYSQL_PORT;
const JAMBONES_MYSQL_PASSWORD = process.env.JAMBONES_MYSQL_PASSWORD;
const JAMBONES_MYSQL_DATABASE = process.env.JAMBONES_MYSQL_DATABASE;
const JAMBONES_MYSQL_CONNECTION_LIMIT = process.env.JAMBONES_MYSQL_CONNECTION_LIMIT;
/* MYSQL Write Connection */
const JAMBONES_MYSQL_WRITE_HOST = process.env.JAMBONES_MYSQL_WRITE_HOST;
const JAMBONES_MYSQL_WRITE_USER = process.env.JAMBONES_MYSQL_WRITE_USER;
const JAMBONES_MYSQL_WRITE_PORT = process.env.JAMBONES_MYSQL_WRITE_PORT;
const JAMBONES_MYSQL_WRITE_PASSWORD = process.env.JAMBONES_MYSQL_WRITE_PASSWORD;
const JAMBONES_MYSQL_WRITE_DATABASE = process.env.JAMBONES_MYSQL_WRITE_DATABASE;
/* Redis */
const JAMBONES_REDIS_SENTINELS = process.env.JAMBONES_REDIS_SENTINELS;
const JAMBONES_REDIS_SENTINEL_MASTER_NAME = process.env.JAMBONES_REDIS_SENTINEL_MASTER_NAME;
const JAMBONES_REDIS_HOST = process.env.JAMBONES_REDIS_HOST;
const JAMBONES_REDIS_PORT = process.env.JAMBONES_REDIS_PORT;
/* DRACHTIO */
const DRACHTIO_HOST = process.env.DRACHTIO_HOST;
const DRACHTIO_PORT = process.env.DRACHTIO_PORT;
const DRACHTIO_SECRET = process.env.DRACHTIO_SECRET;
/* Application */
const JAMBONES_TIME_SERIES_HOST = process.env.JAMBONES_TIME_SERIES_HOST;
const JAMBONES_LOGLEVEL = process.env.JAMBONES_LOGLEVEL;
const NODE_ENV = process.env.NODE_ENV;
const SBC_PUBLIC_ADDRESS_KEEP_ALIVE_IN_MILISECOND = process.env.SBC_PUBLIC_ADDRESS_KEEP_ALIVE_IN_MILISECOND;
const JAMBONES_HOSTING = process.env.JAMBONES_HOSTING;
const EXPIRES_INTERVAL = process.env.EXPIRES_INTERVAL;
const CHECK_EXPIRES_INTERVAL = process.env.CHECK_EXPIRES_INTERVAL;
const JAMBONES_CLUSTER_ID = process.env.JAMBONES_CLUSTER_ID ;
const JAMBONES_REGBOT_CONTACT_USE_IP = process.env.JAMBONES_REGBOT_CONTACT_USE_IP;
const JAMBONES_REGBOT_MIN_EXPIRES_INTERVAL = process.env.JAMBONES_REGBOT_MIN_EXPIRES_INTERVAL;
const JAMBONES_REGBOT_DEFAULT_EXPIRES_INTERVAL = process.env.JAMBONES_REGBOT_DEFAULT_EXPIRES_INTERVAL;
const JAMBONES_REGBOT_BATCH_SLEEP_MS = process.env.JAMBONES_REGBOT_BATCH_SLEEP_MS || 250;
const JAMBONES_REGBOT_BATCH_SIZE = process.env.JAMBONES_REGBOT_BATCH_SIZE || 10;
const OPTIONS_RESPONSE_REMOVE = process.env.OPTIONS_RESPONSE_REMOVE?.split(',').map(Number) || [];
const REGISTER_RESPONSE_REMOVE = process.env.REGISTER_RESPONSE_REMOVE?.split(',').map(Number) || [];
const JAMBONES_REGBOT_USER_AGENT = process.env.JAMBONES_REGBOT_USER_AGENT ;
const JAMBONES_REGBOT_FAILURE_RETRY_INTERVAL = process.env.JAMBONES_REGBOT_FAILURE_RETRY_INTERVAL;
const JAMBONES_REGBOT_REGISTER_FAILURE_THRESHOLD = process.env.JAMBONES_REGBOT_REGISTER_FAILURE_THRESHOLD;
// how long (ms) to wait for a SIP response to a REGISTER before assuming it was lost and retrying
const JAMBONES_REGBOT_RESPONSE_TIMEOUT = process.env.JAMBONES_REGBOT_RESPONSE_TIMEOUT;
/* AWS Auto Scaling: hand off the regbot role when this instance is being scaled in */
const AWS_LIFECYCLE_DRAIN = ['1', 'true', 'yes']
.includes((process.env.AWS_LIFECYCLE_DRAIN || '').trim().toLowerCase());
/* Server control - external topology discovery and other server-control features (disabled unless truthy) */
const JAMBONES_SERVER_CONTROL = process.env.JAMBONES_SERVER_CONTROL;
module.exports = {
JAMBONES_MYSQL_HOST,
JAMBONES_MYSQL_USER,
JAMBONES_MYSQL_PORT,
JAMBONES_MYSQL_PASSWORD,
JAMBONES_MYSQL_DATABASE,
JAMBONES_MYSQL_CONNECTION_LIMIT,
JAMBONES_MYSQL_WRITE_HOST,
JAMBONES_MYSQL_WRITE_USER,
JAMBONES_MYSQL_WRITE_PORT,
JAMBONES_MYSQL_WRITE_PASSWORD,
JAMBONES_MYSQL_WRITE_DATABASE,
JAMBONES_REDIS_SENTINELS,
JAMBONES_REDIS_SENTINEL_MASTER_NAME,
JAMBONES_REDIS_HOST,
JAMBONES_REDIS_PORT,
DRACHTIO_HOST,
DRACHTIO_PORT,
DRACHTIO_SECRET,
JAMBONES_TIME_SERIES_HOST,
JAMBONES_LOGLEVEL,
NODE_ENV,
SBC_PUBLIC_ADDRESS_KEEP_ALIVE_IN_MILISECOND,
JAMBONES_HOSTING,
EXPIRES_INTERVAL,
CHECK_EXPIRES_INTERVAL,
JAMBONES_CLUSTER_ID,
JAMBONES_REGBOT_CONTACT_USE_IP,
JAMBONES_REGBOT_MIN_EXPIRES_INTERVAL,
JAMBONES_REGBOT_DEFAULT_EXPIRES_INTERVAL,
JAMBONES_REGBOT_BATCH_SLEEP_MS,
JAMBONES_REGBOT_BATCH_SIZE,
OPTIONS_RESPONSE_REMOVE,
REGISTER_RESPONSE_REMOVE,
JAMBONES_REGBOT_USER_AGENT,
JAMBONES_REGBOT_FAILURE_RETRY_INTERVAL,
JAMBONES_REGBOT_REGISTER_FAILURE_THRESHOLD,
JAMBONES_REGBOT_RESPONSE_TIMEOUT,
JAMBONES_SERVER_CONTROL,
AWS_LIFECYCLE_DRAIN
};