fatedier/frp · error

read newVisitorConnRespMsg error: %v

Error message

read newVisitorConnRespMsg error: %v

What it means

Visitor sent NewVisitorConn but failed to read the NewVisitorConnResp reply within the 10-second read deadline set just above this call (SetReadDeadline(now+10s)). The server never answered in time or the connection died while waiting, and the deadline converted that into an i/o timeout.

Source

Thrown at client/visitor/visitor.go:192

		RunID:          v.helper.RunID(),
		ProxyName:      targetProxyName,
		SignKey:        util.GetAuthKey(cfg.SecretKey, now),
		Timestamp:      now,
		UseEncryption:  cfg.Transport.UseEncryption,
		UseCompression: cfg.Transport.UseCompression,
	}
	err = visitorConn.WriteMsg(newVisitorConnMsg)
	if err != nil {
		visitorConn.Close()
		return nil, fmt.Errorf("send newVisitorConnMsg to server error: %v", err)
	}

	_ = visitorConn.SetReadDeadline(time.Now().Add(10 * time.Second))
	var newVisitorConnRespMsg msg.NewVisitorConnResp
	err = visitorConn.ReadMsgInto(&newVisitorConnRespMsg)
	if err != nil {
		visitorConn.Close()
		return nil, fmt.Errorf("read newVisitorConnRespMsg error: %v", err)
	}
	_ = visitorConn.SetReadDeadline(time.Time{})

	if newVisitorConnRespMsg.Error != "" {
		visitorConn.Close()
		return nil, fmt.Errorf("start new visitor connection error: %s", newVisitorConnRespMsg.Error)
	}
	return visitorConn, nil
}

func wrapVisitorConn(conn io.ReadWriteCloser, cfg *v1.VisitorBaseConfig) (io.ReadWriteCloser, func(), error) {
	rwc := conn
	if cfg.Transport.UseEncryption {
		var err error
		rwc, err = libio.WithEncryption(rwc, []byte(cfg.SecretKey))
		if err != nil {
			return nil, func() {}, fmt.Errorf("create encryption stream error: %v", err)
		}

View on GitHub (pinned to 6c8a8d0a97)

Solutions

  1. Check frps health and logs; a stalled server is the most common cause.
  2. Verify matching frpc/frps versions; version skew can make the server ignore the visitor message.
  3. Reproduce with packet capture (tcpdump on serverPort) to see whether a reply was sent at all.
  4. Ensure keepalive/heartbeat settings detect dead paths early; the visitor manager retries automatically.
  5. Confirm the address you connect to is frps, not another TLS service that will not reply.
Defensive patterns

Strategy: retry

Try / catch

if err := visitorConn.ReadMsgInto(&resp); err != nil {
    visitorConn.Close()
    if ne, ok := err.(net.Error); ok && ne.Timeout() {
        // 10s deadline hit: server stalled or path broken; retry whole dial
    }
    return err
}

Prevention

When it happens

Trigger: visitorConn.ReadMsgInto(&newVisitorConnRespMsg) errors: server accepted the conn but stalled, server closed without replying, half-open connection after NAT reaping, or a malformed reply that fails message decoding.

Common situations: frps under heavy load or with a blocked event loop; middlebox dropping the return direction; server killed between accept and reply; TLS mismatch making the reply stream undecodable; frpc/frps protocol skew after upgrade so the server ignores the message.

Related errors


AI-assisted analysis of fatedier/frp@6c8a8d0a97 (2026-08-15). Data as JSON: /api/errors/573d3b09ceac2fd2. Report an issue: GitHub.