jeromq
jeromq copied to clipboard
IllegalStateException: errno 4
When closing the ZContext I'm receiving the quite unclear message errno 4. What does it mean?
The stacktrace: java.lang.IllegalStateException: errno 4 at zmq.Ctx.terminate(Ctx.java:272) at org.zeromq.ZMQ$Context.term(ZMQ.java:627) at org.zeromq.ZContext.destroy(ZContext.java:116) at org.zeromq.ZContext.close(ZContext.java:348) at .... my code .....
Using: JeroMQ 0.5.1 and Java OpenJDK 11.0.3. This occurs occasionally on windows and linux in our integration tests. These tests open and close many contexts in succession.
I believe it might mean the channel was closed: see this commit https://github.com/zeromq/jeromq/pull/652/commits/8b647d5da05063aa80971e4fa64ea054bdf72456
When i close the socket, i get this exception in the thread that is pending on recv(). Therefore the proper action may be to stop your receiver thread.
This was changed somewhere between 0.3.6 and 0.5.1: i think in 0.3.6, on that event, i got some exception having getCause() instanceof java.nio.channels.ClosedChannelException
Getting this org.zeromq.ZMQException: Errno 4 (zmq.ZError.EINTR) looks similar to receiving from a socket and getting an InterruptedException in java because the socket got closed.
Open question: Can we improve the error message?
This Enum: https://github.com/zeromq/jeromq/blob/master/src/main/java/org/zeromq/ZMQ.java#L429 needs more messages to be implemented. Are they available in libzmq ?
Revisiting this issue with 0.5.2 (which is in use for some time). The results are the same. Today I noticed something new on STD out: java.util.ConcurrentModificationException at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1493) at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1516) at zmq.SocketBase.processTerm(SocketBase.java:993) at zmq.Own.terminate(Own.java:180) at zmq.SocketBase.startReaping(SocketBase.java:898) at zmq.Reaper.processReap(Reaper.java:100) at zmq.ZObject.processCommand(ZObject.java:107) at zmq.Command.process(Command.java:75) at zmq.Reaper.inEvent(Reaper.java:79) at zmq.poll.Poller.run(Poller.java:273) at java.base/java.lang.Thread.run(Thread.java:834)
Things I would like:
- The concurrent modification as the cause exception in the IllegalStateException (from the description).
- No longer reporting the stacktrace on STD out.
- An improved error message.
- Improved shutdown handling in case of multithreading.
Any of the above feasible?