-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
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
issues with setidentity #250
Comments
Thanks for filing the issue! It's always great to hear about cases that are non obvious to other people. I appreciate the feedback! |
I met the same issue, thank you @Irooniam |
This doesn't seem correct, at least not anymore perhaps. func (c *czmqSocketClient) connect() (err error) {
addr := fmt.Sprintf("tcp://%s:%d", c.masterHost, c.masterPort)
dealer := goczmq.NewSock(goczmq.Dealer)
dealer.SetIdentity(c.identity)
err = dealer.Connect(addr)
if err != nil {
return err
}
c.dealerSocket = dealer
log.Printf("Boomer is connected to master(%s) press Ctrl+c to quit.\n", addr)
go c.recv()
go c.send()
return nil
}
|
Figured it out for the newer version.
|
Some socket options needing to be set before a bind or connect on a socket are things that definitely tripped me up when I first started using ZeroMQ, even before I started writing GoCZMQ. I think it's a great suggestion to make it more visible in the documentation and can do so. @gclair note that outside of the new socket options in my latest release your example has one other problem: ZeroMQ sockets are not thread safe. You should not spawn a receive or a send via a go routine. While it may sometimes work, it is almost guaranteed to eventually cause a problem. |
Oops, thanks for the heads up. Because Sock.RecvFrame is a blocking call, how can I read and write in a single goroutine? |
@myzhan take a look at the poller - https://github.com/zeromq/goczmq/blob/master/poller.go https://github.com/zeromq/goczmq/blob/master/poller_test.go |
@taotetek Thanks, if I put reading and writing in a goroutine, I can select on a time.Ticker to do polling. |
Hello,
I think it would be really helpful to point out in the documentation that you need to set the identity of the socket before you connect.
The following will not set the correct identity
dealer, err := goczmq.NewDealer("tcp://127.0.0.1:5555")
dealer.SetIdentity("magic")
However this does work:
dealer := goczmq.NewSock(goczmq.Dealer)
dealer.SetIdentity("magic")
err = dealer.Connect("tcp://127.0.0.1:5555")
Also, if you could provide example on how to setoptions via NewDealer that would be awesome.
Thanks much.
The text was updated successfully, but these errors were encountered: