We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I create sub, and then Listen() and set OptionSubscribe, it never subscribe to accepted connections.
Listen()
OptionSubscribe
This is example of code which describe the issue:
ctx := context.Background() sub := zmq4.NewSub(ctx) err := sub.Listen("tcp://*:1234") // listen if err != nil { log.Fatalf("could not listen: %v", err) } err = sub.SetOption(zmq4.OptionSubscribe, "") // subscribe for all messages if err != nil { log.Fatalf("could not subscribe to topic %v", err) } go func() { for { msg, err := sub.Recv() // never gets message because OptionSubscribe was not applied after connection was accepted. if err != nil { log.Printf("could not recv message: %v", err) } else { fmt.Printf("recv %+v\n", msg) } } }() pub := zmq4.NewPub(ctx) err = pub.Dial("tcp://*:1234") if err != nil { log.Fatalf("could not dial: %v", err) } for { msg := zmq4.NewMsgString("test abc") err := pub.Send(msg) if err != nil { log.Printf("could send message: %v", err) } fmt.Printf("msg send\n") time.Sleep(time.Second) }
Workaround: when I add one goroutine which in cycle call Subscribe() it works - but it is not effective and unreliable ...
Subscribe()
ctx := context.Background() sub := zmq4.NewSub(ctx) err := sub.Listen("tcp://*:1234") if err != nil { log.Fatalf("could not listen: %v", err) } err = sub.SetOption(zmq4.OptionSubscribe, "") if err != nil { log.Fatalf("could not subscribe to topic %v", err) } go func() { for { msg, err := sub.Recv() if err != nil { log.Printf("could not recv message: %v", err) } else { fmt.Printf("recv %+v\n", msg) } } }() // set subscription too all accepted socket go func() { for { err = sub.SetOption(zmq4.OptionSubscribe, "") if err != nil { log.Printf("could not subscribe to topic %v", err) } fmt.Printf("subscribe\n") time.Sleep(time.Second) } }() pub := zmq4.NewPub(ctx) err = pub.Dial("tcp://*:1234") if err != nil { log.Fatalf("could not dial: %v", err) } for { msg := zmq4.NewMsgString("test abc") err := pub.Send(msg) if err != nil { log.Printf("could send message: %v", err) } fmt.Printf("msg send\n") time.Sleep(time.Second) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When I create sub, and then
Listen()
and setOptionSubscribe
, it never subscribe to accepted connections.This is example of code which describe the issue:
Workaround: when I add one goroutine which in cycle call
Subscribe()
it works - but it is not effective and unreliable ...The text was updated successfully, but these errors were encountered: