zeromq / goczmq

goczmq is a golang wrapper for CZMQ.
Mozilla Public License 2.0
591 stars 94 forks source link

REQ socket in parallel benchmark #268

Closed Trial97 closed 9 months ago

Trial97 commented 5 years ago

Hi

Can you please help me understand why when I try to send and receive messages with a REQ socket in parallel I receive the error: send frame error?

Here is my snippet:

func BenchmarkCZmqParalel(b *testing.B) {
    client := goczmq.NewReqChanneler(fmt.Sprintf("tcp://127.0.0.1:%d", czmq_port))
    go func() {
        err := <-client.ErrChan
        b.Fatal(err)
    }()
    b.ResetTimer()
    b.RunParallel(func(pb *testing.PB) {
        for pb.Next() {
            client.SendChan <- [][]byte{[]byte("Message")}
            <-client.RecvChan
        }
    })
} 

Many thanks in advance