I am running NATS in cluster mode:
docker run -d --network host nats -p 4222 -cluster nats://127.0.0.1:6222
docker run -d --network host nats -p 4333 -cluster nats://127.0.0.1:6333 -routes nats://127.0.0.1:6222
docker run -d --network host nats -p 4444 -cluster nats://127.0.0.1:6444 -routes nats://127.0.0.1:6222
docker run -d --network host nats -p 4555 -cluster nats://127.0.0.1:6555 -routes nats://127.0.0.1:6222
And I connect as shown in the following code:
conn, err := nats.Connect("127.0.0.1:4333,127.0.0.1:4444,127.0.0.1:4555")
if err != nil {
return err
}
encoder := EncodedConn{}
nats.RegisterEncoder("encodedconn", encoder)
encodedConn, err := nats.NewEncodedConn(conn, "encodedconn")
if err != nil {
return err
}
Now when I try to publish a message or send a request I always get the Bytes slice is empty error. However, when I run nats in non-cluster mode as a single-node, then it works just fine.
To clarify, when making a request that may take up to a minute to respond, the message is delivered to the listening party, but the client does not wait and it immediately shows that error.
What is this problem and how can it be solved?