Skip to content

Agent-Controller WebSocket Communication#475

Open
Zakaria-Kofiro wants to merge 6 commits intomasterfrom
zkofiro/agent-controller-websocket
Open

Agent-Controller WebSocket Communication#475
Zakaria-Kofiro wants to merge 6 commits intomasterfrom
zkofiro/agent-controller-websocket

Conversation

@Zakaria-Kofiro
Copy link
Copy Markdown
Collaborator

…5.4)

see .claude/CLAUDE.md for full implementation plan and context

title: -

Please make sure these check boxes are checked before submitting

  • ** Squashed Commits **
  • ** All Tests Passed ** - mvn clean test -P default

** PR review process **

  • Requires one +1 from a reviewer
  • Repository owners will merge your PR once it is approved.

zkofiro added 3 commits April 20, 2026 14:38
…5.4)

see .claude/CLAUDE.md for full implementation plan and context
… session security

- add CDI producer to bridge Spring WS handler bean into JobManager injection
- enforce fallback=false: skip HTTP when WS enabled but no session exists
- bind session identity: one instanceId per WS session, reject rebind
- require hello before accepting any other frame type
- unknown commands now ack as failed, not ok
- single-flight reconnect guard prevents parallel reconnect threads
- bound appliedCommandIds set to prevent unbounded memory growth
- remove wildcard origins, use setAllowedOriginPatterns
- add tests: frame-before-hello, identity rebind, same-identity re-hello
- fallback=false now enforced when wsSender is null or instanceId unmatched
- both sendCommand() and startTest() guard all wsEnabled branches
- agentLastSeen cleaned up in afterConnectionClosed and handleTransportError
@Zakaria-Kofiro Zakaria-Kofiro changed the title Agent-Controller Web Communication Agent-Controller WebSocket Communication Apr 21, 2026
zkofiro added 3 commits April 22, 2026 15:32
ContextLoader.getCurrentWebApplicationContext() returns null in Spring Boot
WAR deployment. Use static holder set at Spring bean init time instead.
TankConfig() may throw during Spring context init if settings XML
is not yet loadable. Fall back to default path to prevent @EnableWebSocket
from silently failing to register the WS handler.
Controller dials out to agents on :8090, establishes persistent WS,
sends commands over WS. Eliminates need for agent→controller inbound
SG rules on controller NLB.

Agent-side:
- AgentCommandWebSocketServer: WS server on :8090, sends hello on
  connect, handles commands via CommandListener.applyCommand()
- APITestHarness: PoC mode bypasses /v2/agent/ready and status PUTs
- APIMonitor: suppresses HTTP status reporting in PoC mode
- CommandListener: extracted applyCommand() shared by HTTP and WS
- AgentStartup: skips settings/support-files download in PoC mode

Controller-side:
- ControllerInitiatedAgentWsClient: outbound WS client with hello
  wait, ack tracking, session management
- JobRequest: after EC2 launch, connects WS to agent, registers via
  jobManager.registerAgentForJob() on hello receipt
- JobManager: routes commands via controller-initiated WS when enabled
- AmazonInstance: propagates PoC flags via EC2 user data

Config:
- controller-initiated-ws-enabled (default false)
- controller-initiated-ws-disable-agent-http (default true)
- controller-initiated-ws-script-path (default script.xml)

Host selection: EAST uses private IP, WEST uses public IP/DNS.
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.

1 participant