XTLS/Xray-core · error
set deadline: %w
Error message
set deadline: %w
What it means
Wraps a failure from deadlines.beginHandshake(), which sets the socket's read/write deadlines at the start of the Minecraft login handshake. The %w chains the underlying net.Conn.SetDeadline error, typically indicating the connection is already closed or the OS refused the deadline (e.g. invalid deadline on a wrapped conn).
Source
Thrown at transport/internet/finalmask/xmc/client.go:79
profiles: profiles,
password: password,
rsaPublicKey: rsaPublicKey,
hostname: hostname,
paddingSchedule: paddingSchedule,
deadlines: newConnectionDeadlines(c),
}, nil
}
func (c *clientConn) handshake() error {
c.handshakeLock.Lock()
defer c.handshakeLock.Unlock()
if c.state != clientStateHandshake {
return nil
}
if err := c.deadlines.beginHandshake(); err != nil {
return fmt.Errorf("set deadline: %w", err)
}
defer func() { _ = c.deadlines.endHandshake() }()
var (
protocolVersion Varint = Varint(775)
serverAddress String = String(c.hostname)
serverPort UnsignedShort = UnsignedShort(25565)
nextState Varint = Varint(2)
)
host, portString, err := net.SplitHostPort(c.c.RemoteAddr().String())
if err == nil {
port, err := strconv.Atoi(portString)
if err == nil {
serverPort = UnsignedShort(port)
}
if serverAddress == "" {View on GitHub (pinned to 7d214f8b09)
Solutions
- Check that the remote address/port is correct and the server accepts connections.
- Unwrap the error (errors.As to *net.OpError) to see whether it is 'use of closed network connection' or a timeout.
- If using a custom net.Conn wrapper, make sure SetDeadline is implemented rather than returning an error.
Defensive patterns
Strategy: try-catch
Try / catch
if err := cc.Handshake(); err != nil {
var opErr *net.OpError
if errors.As(err, &opErr) && opErr.Op == "set-deadline" {
// conn already dead or wrapper lacks deadline support
_ = conn.Close()
return retryDial(ctx)
}
return err
} Prevention
- Ensure custom net.Conn wrappers implement SetDeadline instead of erroring.
- Check conn state (peer closed, RST) before starting the handshake on reused sockets.
When it happens
Trigger: Calling handshake() on a conn that the peer already closed, or on a custom net.Conn wrapper whose SetDeadline returns an error. Timeout enforcement begins here, so dead conns surface at this point rather than at the first write.
Common situations: Server closed the TCP connection during a previous phase; aggressive server-side connection timeouts; passing a pipe or mock conn into the transport without deadline support.
Related errors
- select padding profile: %w
- write handshake packet: %w
- write login start: %w
- read encryption request: %w
- bad encrypt request packet id
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/de6e356659c6c509.
Report an issue: GitHub.