|
@@ -2,11 +2,11 @@
|
|
|
|
|
|
|
|
gRPC sends HTTP2 pings on the transport to detect if the connection is down.
|
|
gRPC sends HTTP2 pings on the transport to detect if the connection is down.
|
|
|
If the ping is not acknowledged by the other side within a certain period, the connection
|
|
If the ping is not acknowledged by the other side within a certain period, the connection
|
|
|
-will be closed. Note that pings are only necessary when there is no activity on the connection.
|
|
|
|
|
|
|
+will be closed. Note that pings are only necessary when there is no activity on the connection.
|
|
|
|
|
|
|
|
## What should I set?
|
|
## What should I set?
|
|
|
|
|
|
|
|
-It should be sufficient for most users to only change `interval` and `timeout` properties, but the
|
|
|
|
|
|
|
+It should be sufficient for most users to only change `interval` and `timeout` properties, but the
|
|
|
following properties can also be useful in certain use cases.
|
|
following properties can also be useful in certain use cases.
|
|
|
|
|
|
|
|
Property | Client | Server | Description
|
|
Property | Client | Server | Description
|
|
@@ -19,7 +19,7 @@ minimumSentPingIntervalWithoutData|.minutes(5)|.minutes(5)|If there are no data/
|
|
|
minimumReceivedPingIntervalWithoutData|N/A|.minutes(5)|If there are no data/header frames being sent: the minimum amount of time expected between receiving successive pings. If the time between successive pings is less than this value, then the ping will be considered a bad ping from the peer. Such a ping counts as a "ping strike".
|
|
minimumReceivedPingIntervalWithoutData|N/A|.minutes(5)|If there are no data/header frames being sent: the minimum amount of time expected between receiving successive pings. If the time between successive pings is less than this value, then the ping will be considered a bad ping from the peer. Such a ping counts as a "ping strike".
|
|
|
maximumPingStrikes|N/A|2|Maximum number of bad pings that the server will tolerate before sending an HTTP2 GOAWAY frame and closing the connection. Setting it to `0` allows the server to accept any number of bad pings.
|
|
maximumPingStrikes|N/A|2|Maximum number of bad pings that the server will tolerate before sending an HTTP2 GOAWAY frame and closing the connection. Setting it to `0` allows the server to accept any number of bad pings.
|
|
|
|
|
|
|
|
-### Client
|
|
|
|
|
|
|
+### Client
|
|
|
|
|
|
|
|
```swift
|
|
```swift
|
|
|
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
|
|
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
|
|
@@ -29,13 +29,14 @@ let keepalive = ClientConnectionKeepalive(
|
|
|
timeout: .seconds(10)
|
|
timeout: .seconds(10)
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-let configuration = ClientConnection.Configuration(
|
|
|
|
|
- target: .hostAndPort("localhost", 443),
|
|
|
|
|
- eventLoopGroup: group,
|
|
|
|
|
- connectionKeepalive: keepalive
|
|
|
|
|
-)
|
|
|
|
|
-
|
|
|
|
|
-let client = ClientConnection(configuration: configuration)
|
|
|
|
|
|
|
+let channel = try GRPCChannelPool.with(
|
|
|
|
|
+ target: .host("localhost"),
|
|
|
|
|
+ transportSecurity: .tls(...),
|
|
|
|
|
+ eventLoopGroup: group
|
|
|
|
|
+) {
|
|
|
|
|
+ // Configure keepalive.
|
|
|
|
|
+ $0.keepalive = keepalive
|
|
|
|
|
+}
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### Server
|
|
### Server
|