Skip to content

feat: Add shutdown handler for client to call and close alive sockets#194

Merged
bjsowa merged 4 commits intoRobotWebTools:ros2from
varunverlencar:feat/issue-193-add-shudown-client-handle
Feb 19, 2026
Merged

feat: Add shutdown handler for client to call and close alive sockets#194
bjsowa merged 4 commits intoRobotWebTools:ros2from
varunverlencar:feat/issue-193-add-shudown-client-handle

Conversation

@varunverlencar
Copy link
Contributor

Add TCP port socket shutdown if not alive

Public API Changes

Add shutdown handler for clients /shutdown

Description

  1. Added changes for shutdown handler and api
  2. Added readme usage instructions
  3. tested on local javascipt UI

#193

@varunverlencar varunverlencar force-pushed the feat/issue-193-add-shudown-client-handle branch from 241cad5 to 07fcdd9 Compare November 14, 2025 02:05
@varunverlencar varunverlencar changed the title issue-193: add shutdown handler for client to call and close alive so… issue-193: add shutdown handler for client to call and close alive sockets Nov 14, 2025
@varunverlencar
Copy link
Contributor Author

varunverlencar commented Nov 14, 2025

tested with ros2 run image_tools cam2image --ros-args -p frequency:=30.0 -p width:=640 -p height:=480 -p burger_mode:=true
and custom UI that listens on web_video_server: you can also use web-browser http://localhost:8080/shutdown?topic=/image
output:

[INFO] [web_video_server-1]: process started with pid [246966]
[web_video_server-1] [INFO] [1763087236.891895946] [web_video_server]: Waiting For connections on 0.0.0.0:8080
[web_video_server-1] [INFO] [1763087282.546730930] [web_video_server]: Handling Request: /stream?topic=/image
[web_video_server-1] [INFO] [1763087282.547466223] [web_video_server]: Streaming topic /image with QoS profile default
[web_video_server-1] [INFO] [1763087290.387515416] [web_video_server]: Handling Request: /shutdown
[web_video_server-1] [INFO] [1763087290.387721288] [web_video_server]: Shutdown request removed 1 stream(s) for topic <all>
[web_video_server-1] [INFO] [1763087290.388883366] [web_video_server]: Handling Request: /shutdown
[web_video_server-1] [INFO] [1763087290.388922029] [web_video_server]: Shutdown request removed 0 stream(s) for topic <all>
[web_video_server-1] [INFO] [1763087290.393034420] [web_video_server]: Removed Stream: /image
[web_video_server-1] [INFO] [1763087296.019929017] [web_video_server]: Handling Request: /stream?topic=/image
[web_video_server-1] [INFO] [1763087296.020282519] [web_video_server]: Streaming topic /image with QoS profile default
[web_video_server-1] [INFO] [1763087299.776973402] [web_video_server]: Handling Request: /shutdown
[web_video_server-1] [INFO] [1763087299.777058013] [web_video_server]: Shutdown request removed 1 stream(s) for topic <all>
[web_video_server-1] [INFO] [1763087299.778284809] [web_video_server]: Handling Request: /shutdown
[web_video_server-1] [INFO] [1763087299.778319854] [web_video_server]: Shutdown request removed 0 stream(s) for topic <all>
[web_video_server-1] [INFO] [1763087299.892136295] [web_video_server]: Removed Stream: /image

@bjsowa
Copy link
Member

bjsowa commented Jan 18, 2026

Sorry for the lack of response. This looks overall good but I recently refactored the project and changed the structure a lot so the changes can't be applied as is. Could you resolve the conflicts or just rewrite the PR for the new structure?

varunverlencar pushed a commit to varunverlencar/web_video_server that referenced this pull request Feb 17, 2026
…bTools#193)

Implements the feature requested in issue RobotWebTools#193: a client-callable HTTP
endpoint that gracefully closes alive MJPEG/stream connections server-side,
preventing lingering TCP sockets when UI components unmount.

Changes:
- StreamerInterface: add virtual stop() (no-op default) and get_client_id()
- StreamerBase: implement stop() (marks inactive, releases connection) and
  get_client_id(); populate client_id_ from 'client_id' query param
- WebVideoServer: register /shutdown route and implement handle_shutdown()
  which stops all streams for a topic, or a single named stream if
  client_id is provided; returns plain-text 'stopped=<count>'
- README: document /shutdown endpoint, parameters, and client_id usage

Rewrite of PR RobotWebTools#194 adapted to the pluginlib-based architecture introduced
in RobotWebTools#192 and the naming/style conventions enforced by RobotWebTools#195.

https://claude.ai/code/session_01F5w6Gj9PefGAEoHz9SS5Wt
…bTools#193)

Implements the feature requested in issue RobotWebTools#193: a client-callable HTTP
endpoint that gracefully closes alive MJPEG/stream connections server-side,
preventing lingering TCP sockets when UI components unmount.

Changes:
- StreamerInterface: add virtual stop() (no-op default) and get_client_id()
- StreamerBase: implement stop() (marks inactive, releases connection) and
  get_client_id(); populate client_id_ from 'client_id' query param
- WebVideoServer: register /shutdown route and implement handle_shutdown()
  which stops all streams for a topic, or a single named stream if
  client_id is provided; returns plain-text 'stopped=<count>'
- README: document /shutdown endpoint, parameters, and client_id usage

Rewrite of PR RobotWebTools#194 adapted to the pluginlib-based architecture introduced
in RobotWebTools#192 and the naming/style conventions enforced by RobotWebTools#195.
@varunverlencar varunverlencar force-pushed the feat/issue-193-add-shudown-client-handle branch from 07fcdd9 to e61d3fb Compare February 18, 2026 23:03
@varunverlencar
Copy link
Contributor Author

@bjsowa made a clean rewrite, also curious to see how good claude was. lets see

varunverlencar and others added 3 commits February 19, 2026 10:36
make pure virtual

Co-authored-by: Błażej Sowa <bsowa123@gmail.com>
make pure virtual

Co-authored-by: Błażej Sowa <bsowa123@gmail.com>
@bjsowa bjsowa changed the title issue-193: add shutdown handler for client to call and close alive sockets feat: add shutdown handler for client to call and close alive sockets Feb 19, 2026
@bjsowa bjsowa changed the title feat: add shutdown handler for client to call and close alive sockets feat: Add shutdown handler for client to call and close alive sockets Feb 19, 2026
@bjsowa bjsowa merged commit 9cdc6b2 into RobotWebTools:ros2 Feb 19, 2026
8 checks passed
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

Comments