mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
lnrpc: use request context in WebSocket proxy
The request context was not properly used to pass it along to the gRPC endpoint which caused streaming calls to still be active on the gRPC side even if the WS side already hung up. We also issue an explicit close on the forwarding writer to signal when the WS side was closed.
This commit is contained in:
parent
29a8661517
commit
5f94ebbd7d
@ -147,12 +147,12 @@ func (p *WebsocketProxy) upgradeToWebSocketProxy(w http.ResponseWriter,
|
||||
}
|
||||
}()
|
||||
|
||||
ctx, cancelFn := context.WithCancel(context.Background())
|
||||
ctx, cancelFn := context.WithCancel(r.Context())
|
||||
defer cancelFn()
|
||||
|
||||
requestForwarder := newRequestForwardingReader()
|
||||
request, err := http.NewRequestWithContext(
|
||||
r.Context(), r.Method, r.URL.String(), requestForwarder,
|
||||
ctx, r.Method, r.URL.String(), requestForwarder,
|
||||
)
|
||||
if err != nil {
|
||||
p.logger.Errorf("WS: error preparing request:", err)
|
||||
@ -181,6 +181,7 @@ func (p *WebsocketProxy) upgradeToWebSocketProxy(w http.ResponseWriter,
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
responseForwarder.Close()
|
||||
requestForwarder.CloseWriter()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
|
Loading…
Reference in New Issue
Block a user