Close McpTransportSession on transport close (#632)
* Client HTTP transports: use McpTransportSession interface instead of concrete types * Streamable HTTP tranports: .closeGracefully closes the session Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
This commit is contained in:
parent
2ee58533d0
commit
9bbfbe573a
1 changed files with 229 additions and 16 deletions
|
|
@ -10,7 +10,7 @@ import eu.rekawek.toxiproxy.model.ToxicDirection;
|
|||
import io.modelcontextprotocol.spec.McpClientTransport;
|
||||
import io.modelcontextprotocol.spec.McpSchema;
|
||||
import io.modelcontextprotocol.spec.McpTransport;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import io.modelcontextprotocol.spec.McpTransportSessionClosedException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -221,9 +221,10 @@ public abstract class AbstractMcpAsyncClientResiliencyTests {
|
|||
// In case of Streamable HTTP this call should issue a HTTP DELETE request
|
||||
// invalidating the session
|
||||
StepVerifier.create(mcpAsyncClient.closeGracefully()).expectComplete().verify();
|
||||
// The next use should immediately re-initialize with no issue and send the
|
||||
// request without any broken connections.
|
||||
StepVerifier.create(mcpAsyncClient.ping()).expectNextCount(1).verifyComplete();
|
||||
// The next tries to use the closed session and fails
|
||||
StepVerifier.create(mcpAsyncClient.ping())
|
||||
.expectErrorMatches(err -> err.getCause() instanceof McpTransportSessionClosedException)
|
||||
.verify();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue