Description
Expected behavior
When the server closes the connection, the client should try to reconnect and eventually shutdown if it can't.
We should implement a retry strategy to re-establish the connection (ideally with an exponential backoff) and gracefully shut down the client if it can't reconnect after n attempts.
Actual behavior
The LambdaRunTimeClient change its internal state but does not attempt to reconnect nor exit.
See this line of code
Steps to reproduce
-
checkout this branch to use the new MockServer
https://github.com/sebsto/swift-aws-lambda-runtime/tree/sebsto/mockserver -
Start the Mock server
LOG_LEVEL=trace swift run
2025-01-15T11:43:07+0100 info MockServer : host="127.0.0.1" maxInvocations=1 port=7000 [MockServer] Server started and listening
- From another terminal, start the HelloWorld example in DEBUG mode.
cd Examples/HelloWorld
export AWS_LAMBDA_RUNTIME_API=127.0.0.1:7000
LAMBDA_USE_LOCAL_DEPS=../.. LOG_LEVEL=trace swift run
uild of product 'MyLambda' complete! (0.12s)
2025-01-15T11:52:18+0100 debug LambdaRuntime : [AWSLambdaRuntimeCore] LambdaRuntime initialized
2025-01-15T11:52:18+0100 trace LambdaRuntime : lambda_ip=127.0.0.1 lambda_port=7000 [AWSLambdaRuntimeCore] Connection to control plane created
[hangs after the /next and /response requests have been processed and the mock server shutdown]
The mock server closes the connection after 2 HTTP request on 1 connection.
The runtime will send the /next
and the /response
requests and then it will stay up and running without retrying the connection.
Adding a print()
statement at line 267 shows that the connection close even is trapped, but no action is taken.
If possible, minimal yet complete reproducer code (or URL to code)
n/a
What version of this project (swift-aws-lambda-runtime
) are you using?
main
Swift version
swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0
Amazon Linux 2 docker image version
n/a