Tencent/WeKnora · error

failed to connect to docreader: %w

Error message

failed to connect to docreader: %w

What it means

Connection error in the docreader gRPC client's connect: grpc.Dial to 'dns:///'+addr failed, so no client connection to the document reader service exists. The %w wraps the gRPC status error; raised from NewGRPCDocumentReader and Reconnect whenever the docreader endpoint is unreachable or the dial is rejected.

Source

Thrown at internal/infrastructure/docparser/grpc_parser.go:70

	if err != nil {
		return fmt.Errorf("failed to build docreader dial options: %w", err)
	}
	if authConfig.TLSEnabled {
		logger.Infof(context.Background(), "TLS enabled for docreader gRPC client")
	}
	if authConfig.AuthToken != "" {
		logger.Infof(context.Background(),
			"Token authentication enabled for docreader gRPC client (TLS=%v)",
			authConfig.TLSEnabled,
		)
	}

	resolver.SetDefaultScheme("dns")

	start := time.Now()
	conn, err := grpc.Dial("dns:///"+addr, opts...)
	if err != nil {
		return fmt.Errorf("failed to connect to docreader: %w", err)
	}
	logger.Infof(context.Background(), "Connected to docreader in %v", time.Since(start))

	p.conn = conn
	p.client = proto.NewDocReaderClient(conn)
	p.addr = addr
	return nil
}

func (p *GRPCDocumentReader) Reconnect(addr string) error {
	p.mu.Lock()
	defer p.mu.Unlock()

	if p.conn != nil {
		_ = p.conn.Close()
		p.conn = nil
		p.client = nil
		p.addr = ""

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Verify the docreader address format and DNS resolution
  2. Check the auth config's transport credentials are valid
  3. Retry via Reconnect once the address/config is corrected
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/infrastructure/docparser/grpc_parser.go:70 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/7c7a993479128b1f. Report an issue: GitHub.