Git Product home page Git Product logo

Comments (12)

schmurfy avatar schmurfy commented on September 28, 2024

Hi,
I am a little confused with your client code, your are waiting until the socket becomes writeable to print a message saying you received a message ? Did you meant on_readable ?

If the text printed are wrong and what you were expecting is that the socket becomes writeable only if there is a server on the other side I do not think it will work that way since zeromq manages the send queue itself, on our side the socket will be immediately writeable and will become no longer writeable only when the zeromq queue is full.

Maybe your code would work as expected if you set the send queue size to 0 but it would completely defeat the purpose of using zeromq.

from em-zeromq.

andrewvc avatar andrewvc commented on September 28, 2024

Agreed w/ schmurfy, you want to hook into on_readable for a req socket, since a req_socket is only readable after a reply has come through.

from em-zeromq.

filterfish avatar filterfish commented on September 28, 2024

If I use on_readable I never get anything back. I can see the reply on the network (using wireshark) but notify_readable is simply never called and consequently neither is on_readable.

from em-zeromq.

schmurfy avatar schmurfy commented on September 28, 2024

There is indeed something broken with REQ/REP while XREQ/XREP work fine, I can see the packet coming at the network level like you but it never triggers the callback. I started looking into it but found nothing yet, I was using zeromq 2.1.6.
@filterfish : which zeromq version did you tried with ? I t may help fix this.

from em-zeromq.

andrewvc avatar andrewvc commented on September 28, 2024

I'll take a look at this later today, but I should mention, xreq/xrep are a much better match for eventmachine. Is there a reason you need blocking behavior?

from em-zeromq.

filterfish avatar filterfish commented on September 28, 2024

@schmurfy I used version 2.1.4 (Debian experimental).

@andrewvc What I'm actually after is to have a way on knowing if there is a listener when sending messages. PUSH would be ideal but with em-zeromq messages are discarded if there is no listener. If I remove the ZMQ::NOBLOCK in Connection#send_msg then the sender blocks but obviously this blocks the whole reactor. Is there a way of having the call to Connection#send_msg block but not block the reactor much in the same way as Context#connect blocks but doesn't block the reactor?

from em-zeromq.

schmurfy avatar schmurfy commented on September 28, 2024

Sending messages with zeromq is never blocking (in the nomal case at least), that is one of the feature of this library, as you pointed it is true that the power zeromq gives us does come with a price: you never known if there is someone on the "other side" of the connection when you send a message.
What happens when you send a message depends on the type of socket you used, you can check here for a complete reference of the sockets types and their behaviors: http://api.zeromq.org/2-1:zmq-socket .
For REQ/XREQ the messages are queued until a listener appears if I remember well.

You can check http://zguide.zeromq.org/page:all, there are great examples of real architecture applied to zeromq, it may helps you find a way to fit your needs with zeromq.

from em-zeromq.

schmurfy avatar schmurfy commented on September 28, 2024

I redid some tests and I am starting to wonder if the problem is not that the fake FD zeromq returns to us just not work as expected with REP/REQ in the 2.1.6 release.
I tried simple blocking read/write tests with ffi-rzmq and they worked as expected.

from em-zeromq.

andrewvc avatar andrewvc commented on September 28, 2024

Hmmm, that's possible. My understanding of how those FDs work is that 0MQ uses them internally to signal communications (like message arrived). Any chance you could gist the tests schmurfy?

from em-zeromq.

andrewvc avatar andrewvc commented on September 28, 2024

BTW, the fake FDs are actually unix sockets.

from em-zeromq.

schmurfy avatar schmurfy commented on September 28, 2024

I have no test that shows a failure, what I did is check that REP/REQ where actually working as intended both in C and with ffi-rzmq, here are both tests if they can be of any use: https://gist.github.com/961468 .

from em-zeromq.

andrewvc avatar andrewvc commented on September 28, 2024

Pending new information, this doesn't seem to be an actual issue.

from em-zeromq.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.