Repository navigation
fix(pjsua): honour --rereg-delay for accounts given on the command line - #21
Open
laconicman wants to merge 2 commits into
Open
laconicman wants to merge 2 commits into
laconicman wants to merge 2 commits into
Conversation
The "Add accounts" loop in app_init() set reg_retry_interval = 300 on every command-line account. The loop runs after option parsing, so the value parsed for --rereg-delay was discarded, and write_account_settings() never wrote the option back because the value always equalled the default. The assignment came in with r3804 on the 1.x branch, a change to the transport adapter sample (pjsip#1383) that does not mention it. The option is older (pjsip#1044). Accounts added at run time by ui_add_account() and cmd_add_account() were never overridden. reg_first_retry_interval = 60, set beside it, is left alone: no option sets it, so the first retry after a failure still comes after about 60 s, and --rereg-delay governs the retries after that.
With --rereg-delay honoured, a 0 now reaches reg_retry_interval, where pjsua-lib documents it as disabling auto re-registration. The option could not produce 0 before, because the app overwrote the value. Say so in the usage text.
laconicman
force-pushed
the
fix/pjsua-rereg-delay-ignored
branch
from
October 6, 2026 13:23
53fb23d to
2dcd7ca
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--rereg-delayhas no effect on accounts given on the command line.pjsua_app_config.cparses it into the account'sreg_retry_interval, but the "Add accounts" loop inapp_init()then setsreg_retry_interval = 300on every such account, after option parsing. For the same reasonwrite_account_settings()never writes the option back. Accounts added at run time (+a,acc add) start frompjsua_acc_config_default()and were never overridden.I found this while writing a SIPp scenario for pjsip#5313. pjsua started before SIPp was listening on TCP, so the first REGISTER was refused and the retry came about a minute later, whatever
--rereg-delaysaid. The option is listed in--helpand written back bywrite_account_settings(), so a user has every reason to expect it to work.The assignment arrived in 1.x r3804 (pjsip#1383, the update of the transport adapter sample), which doesn't mention it.
--rereg-delayitself is older (pjsip#1044).Two commits:
67453e8a— dropreg_retry_interval = 300. The parsed value now reachespjsua_acc_add(), and the config dump writes it back. Thereg_first_retry_interval = 60next to it is left alone on purpose: no option sets it, so the first retry after a failure still comes after about 60 s, and--rereg-delaygoverns the retries after that. In my SIPp case that means the first retry is still a minute away, so this does not shorten it; I worked around it by registering at run time with+a.2dcd7caa— say in--helpthat--rereg-delay=0disables retries. That is what 0 means forreg_retry_intervalin pjsua-lib, and the option could not produce 0 before. A non-numeric value parses as 0 and so disables retries too, as it would for--reg-use-proxy; I did not add validation.Testing
pjsua on macOS against a closed TCP port, reading the "Scheduling re-registration retry for acc 1 in N seconds" log lines:
--rereg-delaya67b8e81bThe first retry is the app's 60 s (randomised by
reg_retry_random_interval, 10 s), and the ones after it follow--rereg-delay. For an interval belowreg_retry_random_interval,schedule_reregistration()currently draws the delay from 0–10 s, so--rereg-delay=1and=9behave alike. That is how the library schedules short intervals today and this PR does not touch it.With
--rereg-delay=30thedcconfig dump now includes--rereg-delay 30; on master it has none.makebuilds without new warnings, andtests/pjsuascripts-run/100_simple.pypasses.