[Bug]: A gateway shows as inactive while another platform-api replica still holds its session
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- docker, go, postgresql
- Domain
- api, backend, distributed-systems
Research direction
Start with platform-api/internal/handler/websocket.go around line 170 and trace how session closure updates the gateway's active state. Check how gateway sessions are represented across replicas and whether the shared Postgres-backed state can determine if any session remains. Done means isActive stays true when another replica still has a live session; add or update coverage for the two-replica case.
Written by the indexing model from the issue text.
Description
Please select the area the issue is related to
Platform API
Please select the aspect the issue is related to
Aspect/API (API backends, definitions, contracts, interfaces, OpenAPI)
Description
With more than one platform-api replica, a gateway is reported as inactive ("isActive": false) while it still has a live session on another replica.
When a gateway's WebSocket session closes, the replica that held it marks the whole gateway inactive if that replica has no other session for it (platform-api/internal/handler/websocket.go:170, len(h.manager.GetConnections(gateway.ID)) == 0). GetConnections only knows this replica's in-memory sessions, so a session the gateway holds on another replica is not counted.
A gateway can have two active tokens, and so two controllers connected at once, each possibly on a different replica. In that case, when one session ends, the gateway shows inactive while the other is still connected and serving. The console shows such a gateway as "Not Active" and greys out its Deploy button (seen on the Deploy page for an inactive gateway).
Since #4315 (revoking a token closes the sessions opened with it), revoking one of the two tokens also triggers this.
Expected: isActive stays true while any replica holds a session for the gateway.
Actual: it becomes false as soon as one replica loses its last session for that gateway.
Related: #1185 (reconnect not updating the state, single replica; closed).
Steps to Reproduce
- Run two platform-api replicas, P1 and P2, on one shared Postgres database, each on its own ports.
- Register a gateway (
POST /api/v0.9/gateways) and mint two tokens for it (POST /api/v0.9/gateways/<id>/tokenstwice). - Start one gateway controller with token 1, connected to P1, and a second controller for the same gateway with token 2, connected to P2.
GET /api/v0.9/gateways/<id>returns"isActive": true; P1 and P2 each hold one session for the gateway.- Stop the first controller (
docker stop <controller-1>). P1 logsWebSocket connection closedfor its session. GET /api/v0.9/gateways/<id>returns"isActive": falseat 2, 8 and 30 seconds after the stop. The second controller is still running and connected to P2, which still holds its session.
Severity Level of the Issue
Severity/Major (Important functionality is broken. Should be prioritized. Doesn't need immediate attention)
Environment Details (with versions)
- Source:
mainata9992d2fe. - Two platform-api replicas built from source, sharing a
postgres:17-alpinedatabase (schema fromschema.postgres.sql). - Gateway controllers and runtimes built from that commit (version 2026.09.24).
- macOS with Rancher Desktop.
- Dominant language
- Go
- Stars
- 85
- Forks
- 137
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 247
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from wso2/api-platform
-
Area/DeveloperPortal Aspect/UI Severity/Minor Type/Bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
wso2/api-platform#4369 ·
Maintainers usually reply within 1 day
-
[Bug]: host-rewrite policy documentation lists fewer allowed host characters than the policy acceptsOpenArea/Policies Aspect/Other Severity/Trivial Type/Bug
Difficulty 1/5 Under an hour Newbie friendliness 91/100
wso2/api-platform#4355 ·
Maintainers usually reply within 1 day
-
Area/Gateway Aspect/API Severity/Minor Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
wso2/api-platform#4348 ·
Maintainers usually reply within 1 day
-
Aspect/AI Aspect/API. Severity/Major
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
wso2/api-platform#4343 ·
Maintainers usually reply within 1 day
-
Area/Policies Aspect/Configuration Severity/Minor Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
wso2/api-platform#4330 ·
Maintainers usually reply within 1 day
All issues in wso2/api-platform
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
mozilla-ai/cq#601 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day