Skip to content

Commit

Permalink
lnc: add timeout to the inital grpc connection with Mailbox
Browse files Browse the repository at this point in the history
Make sure that we do not hold forever if we are not able to dial with
the maiblox service.

This could happen in cases where a passphrase is being reused
and the secret key has already been negotiated for example.
  • Loading branch information
positiveblue committed Feb 12, 2024
1 parent f4f593d commit bc255c0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lnc/lnc.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,11 @@ func (n *NodeConn) newConn(session *Session, opts ...grpc.DialOption) (*conn,
}
dialOpts = append(dialOpts, opts...)

ctxt, cancelT := context.WithTimeout(ctxc, DefaultConnectionTimetout)
defer cancelT()

grpcClient, err := grpc.DialContext(
ctxc, session.MailboxAddr, dialOpts...,
ctxt, session.MailboxAddr, dialOpts...,
)
if err != nil {
cancel()
Expand Down

0 comments on commit bc255c0

Please sign in to comment.