Comments (12)
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.
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.
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.
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.
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.
@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.
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.
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.
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.
BTW, the fake FDs are actually unix sockets.
from em-zeromq.
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.
Pending new information, this doesn't seem to be an actual issue.
from em-zeromq.
Related Issues (15)
- zmq 3.1 HOT 9
- undefined method `errno' for ZMQ:Module HOT 3
- Request-response pattern not working HOT 17
- setsockopt needs to happen before bind or connect HOT 7
- api changes / refactoring HOT 27
- rzmq compat breaks ffi-rzmq HOT 2
- Use ffi-rzmq 0.9.6 HOT 1
- Inproc-only sockets doesn't work HOT 3
- #send_msg is calling #notify_readable causing messages to stack up HOT 14
- [Question] Usage Warning Garbage Collector HOT 4
- Readable/writable attributes missing for Xsub/Xpub sockets HOT 2
- ROUTER and DEALER are switched HOT 4
- failing specs HOT 4
- em-zeromq 0.2.1 on rubygems.org not working with ffi-rzmq 0.9.0 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from em-zeromq.