Skip to content

fix: Refresh SIP settings on server config change - #216

Merged
edospadoni merged 1 commit into
mainfrom
fix/sip-config-refresh
Sep 18, 2026
Merged

edospadoni merged 1 commit into
mainfrom
fix/sip-config-refresh

Conversation

@edospadoni

@edospadoni edospadoni commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Summary

NethLink parsed config.production.js only at credential login and cached sipHost and sipPort in the account. When NethVoice reassigned the SIP port, typically after an update, those cached values went stale and the PhoneIsland could no longer register with Janus. The user was left with a permanent connection error banner and the only workaround was to log out and log back in. Restarting the app was not enough, because autologin reused the saved account as-is whenever the JWT was still valid.

Two changes fix this:

  • At startup, autologin re-reads the server config in both the valid-token and the expired-token path, and persists the new values.
  • While running, two independent triggers detect a change and reload the PhoneIsland so it re-registers with the new port. The first is the socket reconnection that follows a server restart. The second is the webrtc_down alert, raised on every failed registration, which acts as a safety net when the config endpoint comes back after the socket. Config checks from the second trigger are debounced to 10 seconds.

The reload is deferred to the end of an active call, so a call in progress is never dropped. A failed config fetch is swallowed and the cached values are kept, so a server that is still restarting can never break autologin.

Also removes PhoneIslandController.reconnect(), its RECONNECT_PHONE_ISLAND event and the matching renderer listener, which had no callers.

How to test

Run the app with DEV=true npm run dev. Main process logs go to stdout.

On the NS8 node, replacing nethvoice1 and 20027 with the instance values:

mid=nethvoice1

# A - advertise a port Asterisk is not listening on
runagent -m $mid podman exec nethcti-ui \
  sed -i "s/20027/20099/" /app/public/config/config.production.js

# B - restart the CTI server, as a module update does
runagent -m $mid systemctl --user restart nethcti-server

# C - restore, and undo any of the tests below
runagent -m $mid systemctl --user restart nethcti-ui

A touches only the container writable layer. Do not edit ASTERISK_SIP_PORT instead: the SIP proxy dispatcher targets it.

# Scenario Steps Expected
1 Port changes while the app is closed quit, A, start server SIP config changed at startup, then the error banner
2 Port changes while the app runs A, B detection, reloading PhoneIsland, banner; C clears it in ~10s with no clicks
3 Plain reconnection, no regression B alone no detection, no reload, stays registered
4 Port changes during a call call, then A, B call survives with audio, reload deferred to call end, one reload on hangup

All four verified against a live NethVoice instance.

NethLink parsed config.production.js only at credential login and
cached sipHost and sipPort in the account. When NethVoice reassigned
the SIP port, typically after an update, the cached values went stale
and the PhoneIsland could no longer register with Janus. The user was
left with a permanent connection error banner, and the only way out
was to log out and log back in.

Autologin now re-reads the server config in both the valid-token and
the expired-token path, so restarting the app is enough to pick up a
new port. While the app is running, two independent triggers detect a
change and reload the PhoneIsland: the socket reconnection that
follows a server restart, and the webrtc_down alert raised on every
failed registration. The reload is deferred to the end of an active
call so that a call in progress is never dropped.

Also drop PhoneIslandController.reconnect() and its
RECONNECT_PHONE_ISLAND event, which had no callers.
@edospadoni edospadoni self-assigned this Sep 17, 2026
@github-actions

Copy link
Copy Markdown

Automatic builds from https://github.com/NethServer/nethlink/actions/runs/35213489796.
Commit: 9fc94ac

Name Platform Link
win-app.exe Windows (x64) Link
macos-app-x64.dmg MacOS (x64) Link
macos-app-arm64.dmg MacOS (arm64) Link
linux-app.AppImage Linux (x64) Link

@edospadoni edospadoni changed the title Refresh SIP settings on server config change fix: Refresh SIP settings on server config change Sep 17, 2026
@andrea-marchionni

Copy link
Copy Markdown
Collaborator

Verified.

@edospadoni
edospadoni merged commit ddc0572 into main Sep 18, 2026
4 checks passed
@edospadoni
edospadoni deleted the fix/sip-config-refresh branch September 18, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants