Skip to content

Commit 2e13b87

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 8cf43a4 commit 2e13b87

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lnc/lnc.go

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

284+
ctxt, cancelT := context.WithTimeout(
285+
context.Background(), DefaultConnectionTimetout,
286+
)
287+
defer cancelT()
284288
grpcClient, err := grpc.DialContext(
285-
ctxc, session.MailboxAddr, dialOpts...,
289+
ctxt, session.MailboxAddr, dialOpts...,
286290
)
287291
if err != nil {
288292
cancel()

0 commit comments

Comments
 (0)