Thanks for the quick reply Matt.
That makes sense...unfortunately that leads to a bigger question for us.
For some reason we keep getting “bad protocol magic V2” when trying to start up nsqd and nsqlookupd instances in our docker cluster managed by kubernetes. nsqd and nsqlookupd are both in separate docker containers. For some reason everything is okay when nsqd and nsqlookupd are pinging back and forth, but as soon as our Producer tries to Publish a gobbed version of a graph in the form of a byte array to a topic, we get the bad protocol magic error. We’re not sure why it only comes up when we try to publish.
Here is where we publish our graph..
func (mc *Migrator) messageHandler() {
g := 0
config := nsq.NewConfig()
broadcast, err := nsq.NewProducer(mc.nsqLookUpdAddr, config)
if err != nil {
fmt.Println(err)
}
out:
for {
select {
case <-mc.quit:
break out
case msg := <-mc.inGraphsChan:
// Receiving graphs here
g += 1
// Decode graph
go func() {
// Get the body, which has the encoded gob of the colorgraph.
gob := msg.Body
b := bytes.NewBuffer(gob)
// Decode message, and get the size.
cg := &ColorGraph{}
cg.GobDecode(b)
mc.IncomingMigrations <- cg
}()
case outGraph := <-mc.OutgoingMigrations:
// Sending graphs out, this is where we PUBLISH and get errors
var b bytes.Buffer
// Create bytes to send
err := outGraph.GobEncode(&b)
if err != nil {
// TODO: handle error
fmt.Println(err)
}
// Publish
if err := broadcast.Publish("migration", b.Bytes()); err != nil {
// TODO: handle error
fmt.Println(err)