nsqio/nsq · error
err.Error()
Error message
err.Error()
What it means
bench_reader panics when the initial nsq.Ready(*rdy).WriteTo(rw) fails while writing the RDY command into the buffered connection to nsqd. WriteTo only fails on connection-level problems (broken pipe, reset, closed conn) — at this point the TCP dial and protocol magic already succeeded. The panic (with err.Error() as the message) crashes the reader goroutine and the whole benchmark, since there is no recover.
Source
Thrown at bench/bench_reader/bench_reader.go:106
panic(err.Error())
}
_, err = nsq.Subscribe(topic, channel).WriteTo(rw)
if err != nil {
panic(err.Error())
}
rdyChan <- 1
<-goChan
_, err = nsq.Ready(*rdy).WriteTo(rw)
if err != nil {
panic(err.Error())
}
err = rw.Flush()
if err != nil {
panic(err.Error())
}
_, err = nsq.ReadResponse(rw)
if err != nil {
panic(err.Error())
}
_, err = nsq.ReadResponse(rw)
if err != nil {
panic(err.Error())
}
var msgCount int64
go func() {
time.Sleep(td)
_ = conn.Close()
}()
for {
resp, err := nsq.ReadResponse(rw)
if err != nil {
if errors.Is(err, net.ErrClosed) {
break
}
panic(err.Error())
}View on GitHub (pinned to 85cf10c09c)
Solutions
- Check nsqd logs for why it dropped the client (invalid command, RDY limit, too many clients).
- Re-run with a sane -rdy (>=1, <= nsqd --max-rdy-count default 2500).
- Ensure the target nsqd is up and reachable before launching bench_reader.
- Drop proxies/LBs between bench and nsqd, or raise their idle timeouts.
Example fix
# before bench_reader -rdy=0 ... # invalid RDY, nsqd drops conn # after bench_reader -rdy=200 ...
Defensive patterns
Strategy: validation
Validate before calling
rdy := flag.Int("rdy", 200, "rdy count")
// after flag.Parse():
if *rdy < 1 || *rdy > 2500 {
log.Fatalf("rdy must be in [1, nsqd max-rdy-count (default 2500)]")
} Try / catch
// bench tools panic; wrap main to get a clean message instead of a stack:
defer func() {
if r := recover(); r != nil {
log.Fatalf("bench_reader failed: %v", r)
}
}() Prevention
- Validate -rdy bounds before connecting.
- Wait for nsqd readiness (e.g. TCP check on 4150) before starting the bench.
- Check nsqd logs immediately after any bench panic — it usually states the rejection reason.
When it happens
Trigger: nsqd closes/resets the connection right after IDENTIFY (bad IDENTIFY payload, max clients reached); the RDY count is invalid (0 or negative, nsqd rejected an earlier command and closed); conn killed by a proxy/firewall; *rdy flag malformed so nsq.Ready produced a bad command.
Common situations: Running bench_reader against an nsqd that hit --max-rdy-count or connection limits; stale conn through LB idle timeout; benchmark started before nsqd finished booting; passing -rdy=0.
Related errors
- err.Error()
- string(data)
- address should not contain scheme
- missing <REV> in --filename-format when gzip, rotation, or w
- listener.Accept() error - %s
AI-assisted analysis of nsqio/nsq@85cf10c09c (2026-08-16).
Data as JSON: /api/errors/f245332f656a6d22.
Report an issue: GitHub.