2

What is the correct zeromq message pattern to choose to implement server, which needs to handle 2 way communication between N-clients (client can issue requests and server can issue notification, which has to be reliable. Thus pub/sub in not going to work here)? What I did: server has REP to handle client requests, REQ to issue notification to client, SUB to get some events. client has REQ to issue requests to server, REP to receive notifications from server, SUB to get some events Then: server has polling to POOLIN over REP and SUB sockets client has polling to POOLIN over REP and SUB sockets

As soon as poll & POOLIN, REP socket calls recv, than do some processing, than send. As soon as poll & POOLIN, SUB socket calls recv.

This schema is not working reliably. If I call poll POLLIN over one REQ socket when data was sent until REQ socket got reply, schema is working, but it's a bit strange.. Am I missing something?

1 Answers1

1

Do you really need blocking REQ/REP sockets? I suggest going fully asynchronous with DEALER on the client, check this:

https://stackoverflow.com/a/19417116/791406

Hope it helps,

Community
  • 1
  • 1
raffian
  • 31,267
  • 26
  • 103
  • 174
  • I thought req-rep was helpful, because blocking calls allows simple code paths. Dealer-router code is going to be an event driven. Thanks for the answer. I will post results. – user2910794 Oct 23 '13 at 19:20
  • Yes, but zeromq is all about events! The problem with blocking REQ/REP is your application will hang indefinitely if something goes wrong. Always send asynchronously, and when receiving, poll with a timeout, at minimum – raffian Oct 23 '13 at 20:09