Skip to content

NethCTI Middleware: sessions are lost after restart #7724

Closed

Description

@edospadoni

Description

When the nethcti-middleware service is restarted, either by pressing Save in the Settings page inside module on NethServer 8 or by manually restarting the service, all user sessions on CTI and NethLink stop working.

After the restart, API requests from NethLink fail with the following error:

10:45:52.993+01:00 [NethLink************] ERROR during fetch GET AxiosError ERR_BAD_REQUEST Request failed with status code 403 https://cti.nethesis.it/api/astproxy/parkings {“headers”:{“Content-Type”:“application/json”,“Authorization”:“Bearer eyJ...”}}

This indicates that the JWT tokens used by clients become invalid or are lost when the middleware restarts.
A persistent token storage mechanism should be implemented so that valid JWT tokens survive service restarts until they naturally expire.

Steps to reproduce

  1. Log in to CTI and NethLink with valid sessions
  2. Restart the nethcti-middleware service by:
    • pressing Save in the NethCTI module on NethServer 8, or
    • manually restarting the service/container
  3. Try to use NethLink or CTI again
  4. Observe that API requests fail with HTTP 403 errors

Expected behavior

User sessions and JWT tokens remain valid after the middleware restart, until token expiration.

Actual behavior

After restarting the middleware, existing JWT tokens become invalid and all CTI/NethLink sessions fail with 403 errors.

Components

  • nethcti-middleware
  • nethlink
  • nethcti-server

Activity

  1. moved this to In Progress in NethVoiceon Nov 3, 2025
  2. added theissue type on Nov 3, 2025
  3. added
    nethvoice
    nethvoice-cti
    on Nov 3, 2025
  4. changed the title [-]NethCTI Middleware: persist sessions if still valid[/-] [+]NethCTI Middleware: sessions are lost after restart[/+] on Nov 3, 2025
  5. moved this from In Progress to Testing in NethVoiceon Nov 14, 2025
  6. 1 remaining item

  7. tommaso-ascani commented on Nov 14, 2025

    @tommaso-ascani

    Test Cases

    Ensure JWT sessions (CTI, Phone Island integration, NethLink) are not invalidated by service restarts, configuration saves, or upgrade.


    Scenarios (run full set in both)

    1. Fresh Install (new NethVoice instance)
    2. Upgrade (existing instance upgraded to this version)

    ❗ $PATH: /home/nethvoiceXX/.local/share/containers/storage/volumes/nethcti-middleware-secrets/_data

    1. Core Login Validation (both scenarios)

    • Log in from:
      • CTI (user session)
      • Phone Island (integration token) → creates token file $PATH/user/phone_island_api_key_web.json
      • NethLink → creates token file $PATH/user/phone_island_api_key_nethlink.json
    • All three must authenticate successfully.

    2. Restart / Reload Actions (with sessions active)

    1. Restart nethcti-middleware
    2. Restart nethcti-server
    3. Press “Save” in NethServer 8 module settings (triggers middleware reload)

    Expected for each action:

    • No logout
    • No 403 errors
    • Continued normal operation (API calls succeed)

    3. Persistence & Files

    Check:

    • $PATH/sessions.json updates on each login/logout.
    • When the last valid CTI JWT is removed, the persistent CTI-server token entry is also removed.
    • In each user folder:
      • $PATH/user/phone_island_api_key_web.json (phone island) token file created on login, removed on logout/revocation.
      • $PATH/user/phone_island_api_key_nethlink.json token file created/removed similarly.
    • After restarts/reloads, files are still present if sessions are active (no orphan duplicates).

    4. Multiple Users / Corner Cases

    • Log in multiple users (e.g. A, B, C) plus Phone Island + NethLink.
    • Perform restarts, log out one user, confirm others remain valid.
    • Watch for anomalies: stale $PATH/sessions.json entries, missing token files, orphan files after logout.

    5. Extra

    1. Enter nethvoice istance from cli (runagent -m nethvoice...)
    2. Run mysql nethcti3 to enter database
    3. Execute select * from auth; to check cti-server persistent token works properly.

    ⚠️ Known Non-Blocking Issue

    • Ignore “WebRTC is unavailable” (Janus-related). Does not indicate auth/session failure.
  8. Amygos commented on Nov 17, 2025

    @Amygos
    Member

    Testing release nethesis/ns8-nethvoice 1.5.1-testing.10

  9. added
    testing
    on Nov 17, 2025
  10. added
    verified
    on Nov 19, 2025
  11. removed
    testing
    on Nov 19, 2025
  12. moved this from Testing to Verified in NethVoiceon Nov 19, 2025
  13. Stell0 commented on Nov 21, 2025

    @Stell0
  14. moved this from Verified to Done in NethVoiceon Nov 21, 2025
  15. removed
    verified
    on Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    nethvoicenethvoice-cti

    Type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions