XTLS/Xray-core · error

unable to set read deadline

Error message

unable to set read deadline

What it means

The inbound connection does not support setting an initial read deadline for the handshake window (SetReadDeadline returned an error); logged at warning and typically harmless for socket-less transports.

Solutions

  1. Inspect .Base(err) to see which connection type rejected the deadline
  2. Ignore if the transport handles timeouts itself
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at proxy/trojan/server.go:154 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/c5ca3da8b5e5eae7. Report an issue: GitHub.

Appendix: source

Thrown at proxy/trojan/server.go:154

}

// GetUsersCount implements proxy.UserManager.GetUsersCount().
func (s *Server) GetUsersCount(context.Context) int64 {
	return s.validator.GetCount()
}

// Network implements proxy.Inbound.Network().
func (s *Server) Network() []net.Network {
	return []net.Network{net.Network_TCP, net.Network_UNIX}
}

// Process implements proxy.Inbound.Process().
func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error {
	iConn := stat.TryUnwrapStatsConn(conn)

	sessionPolicy := s.policyManager.ForLevel(0)
	if err := conn.SetReadDeadline(time.Now().Add(sessionPolicy.Timeouts.Handshake)); err != nil {
		return errors.New("unable to set read deadline").Base(err).AtWarning()
	}

	first := buf.FromBytes(make([]byte, buf.Size))
	first.Clear()
	firstLen, err := first.ReadFrom(conn)
	if err != nil {
		return errors.New("failed to read first request").Base(err)
	}
	errors.LogInfo(ctx, "firstLen = ", firstLen)

	bufferedReader := &buf.BufferedReader{
		Reader: buf.NewReader(conn),
		Buffer: buf.MultiBuffer{first},
	}

	var user *protocol.MemoryUser

	napfb := s.fallbacks

View on GitHub (pinned to 7d214f8b09)