Skip to content

NethCTI server: each video source frame is sent once per connected client → nethcti-server runs out of memory #8294

Closed

Description

@tonyco97

Description

Steps to reproduce

  • On a NethVoice with one or more video sources configured and many CTI clients connected
  • Open the video sources page of the CTI with one or more users
  • Watch the memory of the nethcti-server process: it grows every second until the process crashes and restarts

Expected behavior

Every frame captured from a video source is sent once to each user subscribed to that source. nethcti-server memory stays stable regardless of the number of connected clients.

Actual behavior

nethcti-server memory grows up to ~2 GB, then the process crashes. On restart all the websocket connections drop, so every CTI client (not only the users watching the cameras) shows a connection error.

Observed on a production installation; lowering the sampling rate (frame-rate = 5000 in rest_cti_streaming) only mitigates it.

Root cause

In com_nethcti_ws.js, evtStreamingSourceChanged broadcasts each frame to the room of the source inside a loop over all the connected websockets:

for (sockid in wsid) {
  wsServer.sockets.in(WS_ROOM[room_name]).emit(EVT_STREAMING_SOURCE_UPDATE, evt);
}

Each subscriber receives the same base64 frame once per connected client (N sockets × M subscribers messages per frame, every frame-rate ms). Reproduced with socket.io 4.8: 150 connected sockets, 3 subscribers, 200 KB frame, 10 frames → ~4500 messages instead of 30 and +930 MB of RSS (vs +16 MB with a single emit).

Suggested fix

Emit the frame once to the room of the source, without the loop over wsid.

Components

  • nethcti-server (branch ns8, shipped in ghcr.io/nethesis/nethvoice-cti-server)
  • NethVoice module 1.8 on NS8

Activity

  1. added this to the NethVoice 1.9 milestone on Nov 6, 2026
  2. added
    nethvoiceBug or features releted to the NethVoice project
    on Nov 6, 2026
  3. added theissue type on Nov 6, 2026
  4. tonyco97 commented on Nov 6, 2026

    @tonyco97
    Author

    Test

    PR: nethesis/nethcti-server#379, nethesis/ns8-nethvoice#1167

    Setup: NethVoice with at least one video source (camera snapshot URL) with frame-rate = 1000, at least 3 users with the video source permission, several other CTI clients connected (web and/or NethLink).

    Test Case 1 - Video source page shows the camera

    • User A opens the video sources page in the CTI: the image of the source is shown and refreshes about every second
    • In the browser devtools (WS frames), user A receives one streamingSourceUpdate per frame, not one per connected client

    Test Case 2 - Multiple viewers

    • Users A, B and C open the video sources page at the same time: every user sees the image updating
    • Each user receives one streamingSourceUpdate per frame

    Test Case 3 - nethcti-server memory stays stable

    • With users A, B and C watching for at least 10 minutes, the memory of nethcti-server (podman stats nethcti-server) stays stable and does not grow towards ~2 GB
    • nethcti-server does not restart and the other CTI clients do not show connection errors

    Test Case 4 - Users not watching

    • A user connected to the CTI but not on the video sources page does not receive any streamingSourceUpdate
  5. added
    nethvoice-ctiThe issue is related to NethLink (NethVoice Web client)
    on Nov 6, 2026
  6. added
    testingPackages are available from testing repositories
    on Nov 6, 2026
  7. moved this from Todo to Testing in NethVoiceon Nov 6, 2026
  8. tonyco97 commented on Nov 6, 2026

    @tonyco97
    Author

    Testing image:

    https://github.com/nethesis/ns8-nethvoice/releases/tag/1.8.0-testing.101
    

    Install command:

    api-cli run update-module --data '{"module_url":"ghcr.io/nethesis/nethvoice:1.8.0-testing.101"  , "instances":["nethvoice<ID>"], "force": true}'
    
  9. edospadoni commented on Nov 9, 2026

    @edospadoni
    Member

    Testing image:

    https://github.com/nethesis/ns8-nethvoice/releases/tag/1.8.0-testing.112
    

    Includes nethesis/nethcti-server#380: video sources are sampled only when at least one user is subscribed to them (follow-up of nethesis/nethcti-server#379).

    Install command:

    api-cli run update-module --data '{"module_url":"ghcr.io/nethesis/nethvoice:1.8.0-testing.112", "instances":["nethvoice<ID>"], "force": true}'
    

    Test Case 5 - No sampling without viewers

    • With no user on the video sources page, nethcti-server does not request frames from the cameras (no streamingSourceChanged events in the nethcti-server logs, or no requests in the camera access log)
    • When a user opens the video sources page, the image appears within about one frame-rate interval and keeps refreshing
    • When the user leaves the page or puts the browser tab in background, sampling stops again; when the tab is visible again, the image resumes updating
  10. removed
    testingPackages are available from testing repositories
    on Nov 9, 2026
  11. moved this from Testing to Verified in NethVoiceon Nov 9, 2026
  12. edospadoni commented on Nov 9, 2026

    @edospadoni
    Member

    Release nethesis/ns8-nethvoice 1.8.0

  13. moved this from Verified to Done in NethVoiceon Nov 9, 2026
  14. edospadoni commented on Nov 9, 2026

    @edospadoni
    Member

    Release nethesis/ns8-nethvoice 1.8.0

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

    nethvoiceBug or features releted to the NethVoice projectnethvoice-ctiThe issue is related to NethLink (NethVoice Web client)verifiedAll test cases were verified successfully

    Type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions