Improve APNs http2 connection health check (#568)
This commit is contained in:
parent
9c51cbc989
commit
01aba27bc0
|
@ -117,6 +117,10 @@ func InitAPNSClient() error {
|
||||||
ApnsClient, err = newApnsClient(certificateKey)
|
ApnsClient, err = newApnsClient(certificateKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if h2Transport, ok := ApnsClient.HTTPClient.Transport.(*http2.Transport); ok {
|
||||||
|
configureHTTP2ConnHealthCheck(h2Transport)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogError.Error("Transport Error:", err.Error())
|
LogError.Error("Transport Error:", err.Error())
|
||||||
|
|
||||||
|
@ -155,11 +159,11 @@ func newApnsClient(certificate tls.Certificate) (*apns2.Client, error) {
|
||||||
IdleConnTimeout: idleConnTimeout,
|
IdleConnTimeout: idleConnTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
transportErr := http2.ConfigureTransport(transport)
|
if h2Transport, err := http2.ConfigureTransports(transport); err != nil {
|
||||||
if transportErr != nil {
|
return nil, err
|
||||||
return nil, transportErr
|
} else {
|
||||||
|
configureHTTP2ConnHealthCheck(h2Transport)
|
||||||
}
|
}
|
||||||
|
|
||||||
client.HTTPClient.Transport = transport
|
client.HTTPClient.Transport = transport
|
||||||
|
|
||||||
return client, nil
|
return client, nil
|
||||||
|
@ -184,9 +188,10 @@ func newApnsTokenClient(token *token.Token) (*apns2.Client, error) {
|
||||||
IdleConnTimeout: idleConnTimeout,
|
IdleConnTimeout: idleConnTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
transportErr := http2.ConfigureTransport(transport)
|
if h2Transport, err := http2.ConfigureTransports(transport); err != nil {
|
||||||
if transportErr != nil {
|
return nil, err
|
||||||
return nil, transportErr
|
} else {
|
||||||
|
configureHTTP2ConnHealthCheck(h2Transport)
|
||||||
}
|
}
|
||||||
|
|
||||||
client.HTTPClient.Transport = transport
|
client.HTTPClient.Transport = transport
|
||||||
|
@ -194,6 +199,11 @@ func newApnsTokenClient(token *token.Token) (*apns2.Client, error) {
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func configureHTTP2ConnHealthCheck(h2Transport *http2.Transport) {
|
||||||
|
h2Transport.ReadIdleTimeout = 1 * time.Second
|
||||||
|
h2Transport.PingTimeout = 1 * time.Second
|
||||||
|
}
|
||||||
|
|
||||||
func iosAlertDictionary(payload *payload.Payload, req PushNotification) *payload.Payload {
|
func iosAlertDictionary(payload *payload.Payload, req PushNotification) *payload.Payload {
|
||||||
// Alert dictionary
|
// Alert dictionary
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue