Problem
StreamConnection::dispatchServerPush() handles server-initiated close (key 0x0016) by sending a CloseResponse and closing the connection. However, no E2E test verifies this behavior. This is a critical path — in production, the server may close connections due to policy violations, resource limits, or administrative actions.
How to trigger
Server-initiated close can be triggered by:
- Deleting a stream while a consumer is subscribed to it (may trigger MetadataUpdate + Close)
- Using the RabbitMQ management API to force-close a connection
- Server shutdown/restart
Expected test
public function testServerInitiatedCloseIsHandledGracefully(): void
{
$connection = Connection::create(...);
$streamName = 'test-server-close-' . uniqid();
$connection->createStream($streamName);
// Force close via management API
// curl -X DELETE http://localhost:15672/api/connections/...
// Next operation should detect the closed connection
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Connection closed');
$connection->createStream('another-stream');
}
Why it matters
- Critical production scenario — servers close connections regularly
- The
dispatchServerPush() Close handler sends a response and calls $this->close(), but this path is untested
- Without this test, regressions in close handling could cause silent data loss
Acceptance criteria
Problem
StreamConnection::dispatchServerPush()handles server-initiated close (key0x0016) by sending a CloseResponse and closing the connection. However, no E2E test verifies this behavior. This is a critical path — in production, the server may close connections due to policy violations, resource limits, or administrative actions.How to trigger
Server-initiated close can be triggered by:
Expected test
Why it matters
dispatchServerPush()Close handler sends a response and calls$this->close(), but this path is untestedAcceptance criteria
isConnected()returnsfalseafter server-initiated close