Skip to content

Commit bc255c0

Browse files
committed
lnc: add timeout to the inital grpc connection with Mailbox
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.
1 parent f4f593d commit bc255c0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lnc/lnc.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,11 @@ func (n *NodeConn) newConn(session *Session, opts ...grpc.DialOption) (*conn,
281281
}
282282
dialOpts = append(dialOpts, opts...)
283283

284+
ctxt, cancelT := context.WithTimeout(ctxc, DefaultConnectionTimetout)
285+
defer cancelT()
286+
284287
grpcClient, err := grpc.DialContext(
285-
ctxc, session.MailboxAddr, dialOpts...,
288+
ctxt, session.MailboxAddr, dialOpts...,
286289
)
287290
if err != nil {
288291
cancel()

0 commit comments

Comments
 (0)