Skip to content

Commit 0ecbc0d

Browse files
Better error log when dialing without internet connection (#5466)
Co-authored-by: Cheuk <90270663+cheukt@users.noreply.github.com>
1 parent 89da1a0 commit 0ecbc0d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

robot/client/client.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,18 @@ func (rc *RobotClient) connectWithLock(ctx context.Context) error {
535535
conn = grpcConn
536536
err = nil
537537
} else {
538+
// A context.DeadlineExceeded from the WebRTC dial implies the client is unable to reach
539+
// the signaling server, which likely means that the client is offline. In that case, if the errors returned from
540+
// grpc dials are also timeouts or mDNS failing to find a candidate, we should remind clients to double-check their internet
541+
// connection and that the machine is on. This should be more helpful than simply returning a chain of context.DeadlineExceeded
542+
// and candidate not found errors.
543+
const connTimeoutURL = "https://docs.viam.com/dev/tools/common-errors/#conn-time-out"
544+
if errors.Is(err, context.DeadlineExceeded) &&
545+
errors.Is(grpcErr, context.DeadlineExceeded) &&
546+
errors.Is(grpcErr, rpc.ErrMDNSNoCandidatesFound) {
547+
return fmt.Errorf("failed to connect to machine within time limit. check network connection, whether the viam-server is running, " +
548+
"and try again. see " + connTimeoutURL + " for troubleshooting steps")
549+
}
538550
err = multierr.Combine(err, grpcErr)
539551
}
540552
}

0 commit comments

Comments
 (0)