XTLS/Xray-core · error

failed to read HTTP response

Error message

failed to read HTTP response

What it means

Error "failed to read HTTP response" thrown in XTLS/Xray-core.

Source

Thrown at main/commands/all/api/shared.go:105

		Timeout: 30 * time.Second,
	}
	resp, err := client.Do(&http.Request{
		Method: "GET",
		URL:    parsedTarget,
		Close:  true,
	})
	if err != nil {
		return nil, fmt.Errorf("failed to dial to %s", target)
	}
	defer resp.Body.Close()

	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("unexpected HTTP status code: %d", resp.StatusCode)
	}

	content, err := buf.ReadAllToBytes(resp.Body)
	if err != nil {
		return nil, errors.New("failed to read HTTP response")
	}

	return content, nil
}

func showJSONResponse(m proto.Message) {
	if isNil(m) {
		return
	}
	if j, ok := creflect.MarshalToJson(m, true); ok {
		fmt.Println(j)
	} else {
		fmt.Fprintf(os.Stdout, "%v\n", m)
		base.Fatalf("error encode json")
	}
}

func isNil(i interface{}) bool {

View on GitHub (pinned to 7d214f8b09)

When it happens

Trigger: Thrown at main/commands/all/api/shared.go:105 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/7c387d99d7a7a72b. Report an issue: GitHub.