diff --git a/client.go b/client.go index 9c02984..a3466d1 100644 --- a/client.go +++ b/client.go @@ -263,6 +263,12 @@ func (c *client) Do(req *Request) (resp *ResponsePipe, err error) { } } + // check if connection exists + if c.conn == nil { + err = fmt.Errorf("client connection has been closed") + return + } + // allocate request ID reqID := c.ids.Alloc() @@ -270,12 +276,6 @@ func (c *client) Do(req *Request) (resp *ResponsePipe, err error) { resp = NewResponsePipe() rwError, allDone := make(chan error), make(chan int) - // check if connection exists - if c.conn == nil { - err = fmt.Errorf("client connection has been closed") - return - } - // if there is a raw request, use the context deadline var ctx context.Context if req.Raw != nil {