hashicorp/nomad · error

unsupported transport

Error message

unsupported transport

What it means

Returned by Client.websocket when the underlying HTTP client's Transport is not an *http.Transport. The websocket dialer needs concrete access to the transport's dial settings; custom or wrapped transport implementations cannot be introspected, so the request is aborted.

Source

Thrown at api/api.go:957

	r, err := c.newRequest("GET", endpoint)
	if err != nil {
		return nil, err
	}
	r.setQueryOptions(q)
	_, resp, err := requireOK(c.doRequest(r)) //nolint:bodyclose // Closing the body is the caller's responsibility.
	if err != nil {
		return nil, err
	}

	return resp.Body, nil
}

// websocket makes a websocket request to the specific endpoint
func (c *Client) websocket(endpoint string, q *QueryOptions) (*websocket.Conn, *http.Response, error) {

	transport, ok := c.httpClient.Transport.(*http.Transport)
	if !ok {
		return nil, nil, errors.New("unsupported transport")
	}
	dialer := websocket.Dialer{
		ReadBufferSize:   4096,
		WriteBufferSize:  4096,
		HandshakeTimeout: c.httpClient.Timeout,

		// values to inherit from http client configuration
		NetDial:         transport.Dial,
		NetDialContext:  transport.DialContext,
		Proxy:           transport.Proxy,
		TLSClientConfig: transport.TLSClientConfig,
	}

	// build request object for header and parameters
	r, err := c.newRequest("GET", endpoint)
	if err != nil {
		return nil, nil, err
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Use a *http.Transport (or api.DefaultConfig's client) instead of a custom RoundTripper wrapper for clients that need websocket endpoints (exec, logs)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at api/api.go:957 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/065af1c6913e878e. Report an issue: GitHub.