Skip to content

Commit 01c2d1c

Browse files
authored
Set AMQP connection idle timeout to 60 seconds. (Azure#21995)
1 parent a0c60af commit 01c2d1c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/handler/ConnectionHandler.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class ConnectionHandler extends Handler {
4242
static final Symbol USER_AGENT = Symbol.valueOf("user-agent");
4343

4444
static final int MAX_FRAME_SIZE = 65536;
45+
static final int CONNECTION_IDLE_TIMEOUT = 60_000; // milliseconds
4546

4647
private final Map<String, Object> connectionProperties;
4748
private final ConnectionOptions connectionOptions;
@@ -113,6 +114,11 @@ public int getMaxFrameSize() {
113114
* @param transport Transport to add layers to.
114115
*/
115116
protected void addTransportLayers(Event event, TransportInternal transport) {
117+
// default connection idle timeout is 0.
118+
// Giving it a idle timeout will enable the client side to know broken connection faster.
119+
// Refer to http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#doc-doc-idle-time-out
120+
transport.setIdleTimeout(CONNECTION_IDLE_TIMEOUT);
121+
116122
final SslDomain sslDomain = Proton.sslDomain();
117123
sslDomain.init(SslDomain.Mode.CLIENT);
118124

0 commit comments

Comments
 (0)