Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion aperture.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,12 @@ func createHashMailServer(cfg *Config) ([]proxy.LocalService, func(), error) {
}

// Wrap the default grpc-gateway handler with the WebSocket handler.
// We enable WebSocket-level pings to keep the underlying connection
// alive through intermediary proxies and load balancers that may
// silently drop idle WebSocket connections.
restHandler := lnrpc.NewWebSocketProxy(
mux, log, 0, 0, clientStreamingURIs,
mux, log, cfg.WsPingInterval, cfg.WsPongWait,
clientStreamingURIs,
)

// Create our proxy chain now. A request will pass
Expand Down
24 changes: 24 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ const (
defaultIdleTimeout = time.Minute * 2
defaultReadTimeout = time.Second * 15
defaultWriteTimeout = time.Second * 30

// defaultWsPingInterval is the default interval at which we send
// WebSocket-level pings to connected clients. This keeps the
// connection alive through intermediary proxies and load balancers
// that may drop idle connections.
defaultWsPingInterval = 30 * time.Second

// defaultWsPongWait is the default duration we wait for a pong
// response after sending a WebSocket ping before considering the
// connection dead.
defaultWsPongWait = 10 * time.Second
)

type EtcdConfig struct {
Expand Down Expand Up @@ -233,6 +244,17 @@ type Config struct {
// Logging controls various aspects of aperture logging.
Logging *build.LogConfig `group:"logging" namespace:"logging"`

// WsPingInterval is the interval at which WebSocket-level pings are
// sent to connected clients. This keeps the underlying WebSocket
// connection alive through intermediary proxies and load balancers.
// Set to 0 to disable.
WsPingInterval time.Duration `long:"wspinginterval" description:"Interval for WebSocket-level ping messages to keep connections alive through proxies."`

// WsPongWait is the duration to wait for a pong response after
// sending a WebSocket-level ping. If no pong is received within this
// duration, the WebSocket connection is considered dead.
WsPongWait time.Duration `long:"wspongwait" description:"Duration to wait for a WebSocket pong response before closing the connection."`

// Blocklist is a list of IPs to deny access to.
Blocklist []string `long:"blocklist" description:"List of IP addresses to block from accessing the proxy."`
}
Expand Down Expand Up @@ -277,6 +299,8 @@ func NewConfig() *Config {
IdleTimeout: defaultIdleTimeout,
ReadTimeout: defaultReadTimeout,
WriteTimeout: defaultWriteTimeout,
WsPingInterval: defaultWsPingInterval,
WsPongWait: defaultWsPongWait,
InvoiceBatchSize: defaultInvoiceBatchSize,
Logging: build.DefaultLogConfig(),
Blocklist: []string{},
Expand Down
Loading