Skip to content

Disconnect device sessions when a device is disabled - #2120

Closed
eriansv wants to merge 1 commit into
traccar:masterfrom
eriansv:feature/device-disconnect
Closed

eriansv wants to merge 1 commit into
traccar:masterfrom
eriansv:feature/device-disconnect

Conversation

@eriansv

@eriansv eriansv commented Nov 26, 2026

Copy link
Copy Markdown

Motivation

Disabling a device only prevents new connections; sessions that are already established keep reporting. The server change (traccar/traccar#6150) closes those sessions automatically and exposes POST /api/devices/{id}/disconnect for manual use.

This change makes the web app call that endpoint when a device is saved with disabled enabled, so the device is disconnected immediately instead of waiting for it to reconnect.

Change

  • DevicePage: keeps the initial disabled value and, when a save changes it from enabled to disabled, calls POST api/devices/{id}/disconnect.
  • EditItemView: awaits onItemSaved so the disconnect request completes before navigating back.

Only the enabled → disabled transition triggers the call; saving an already disabled device or re-enabling it does nothing.

Testing

  • npx eslint src/settings/DevicePage.jsx src/settings/components/EditItemView.jsx passes.
  • Manual: with a connected device, enable Disabled and save; the device disappears from ss -tn sport=:5013, the server logs Closed session for device N, and the device is rejected on reconnect.

Depends on traccar/traccar#6150.

@tananaev

Copy link
Copy Markdown
Member

I don't think we need this frontend change. Disconnecting active sessions when a device is disabled should be handled entirely by the server. The web app should only need to save the device's disabled state.

@eriansv

eriansv commented Nov 27, 2026

Copy link
Copy Markdown
Author

Closing this one, as you said: disconnecting a disabled device should be handled entirely by the server, so no frontend change is needed.

@eriansv eriansv closed this Nov 27, 2026
@eriansv
eriansv deleted the feature/device-disconnect branch November 27, 2026 01:31
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