Skip to content

Message Loss JeroMQ 0.5. due to zmq security #1015

Open
@RekikMohamed

Description

@RekikMohamed

I am subscribing to an external data source.
I used two subscriber:

  1. .Net6 with NetMQ
  2. Java JeroMQ

In both i am subscribing to a topic and printing the data.
The message count in .Net6 is 33
The message count in Java JeroMQ is less than 10


 @Override
 public void run() {
        final String ID_MSG = "DataZMQSubscriber : ";
        int messageCount = 0;
        try {
            this.closeSocket();
            Thread.sleep(100);
            for (String topic : this.topics) {
                this.addTopic(topic);
            }
            this.getSubscriberSocket().setRcvHWM(0);
            while (this.listening) {
                try {
                    String data = this.getSubscriberSocket().recvStr();
                    if (data == null || data.isEmpty()) {
                        continue;
                    }
                    if(data.contains("\"Instance1\"")) {
                        messageCount ++;
                        System.out.println("raw data:  " + data);
                        System.out.println("message Count:  " + messageCount);
                    }

                } catch (Exception exception) {
                }
            }
        } catch (Exception exp) {
        } finally {
        }
    }

I also tried a sample application using JeroMQ and still having a massive data loss:

import org.zeromq.ZContext;
import org.zeromq.ZMQ;

public class main {
    private static Object SocketType;
    private static ZMQ.Curve.KeyPair serverPair = new ZMQ.Curve.KeyPair("P7*N&z+Nd#:h}bHBM0pjAQx}}>-G:g]vx$T=yiQr", "}r!y</A*iP[iAE-1feWqiJL@/NfKy6.eN?o@Pn{L");

    public static void main(String[] args) {
        try (ZContext context = new ZContext()) {
            System.out.println("Starting Z Context");
            ZMQ.Socket sub = context.createSocket(org.zeromq.SocketType.SUB);
            sub.connect("tcp://192.168.7.240:31554");
            int messageCount = 0;
            sub.subscribe("d37f6e3d-1cc8-4532-8c5f-cff565509182".getBytes());
            sub.setRcvHWM(0);
            sub.setCurveServerKey(serverPair.publicKey.getBytes());

            sub.setCurveSecretKey(serverPair.secretKey.getBytes());
            sub.setCurvePublicKey(serverPair.publicKey.getBytes());
            System.out.println("Subscribed");

            while (true) {
                String message = sub.recvStr();
                if(message.contains("\"Instance1\"")) {
                    messageCount ++;
                    System.out.println("raw data:  " + message);
                    System.out.println("message Count:  " + messageCount);
                }
            }
        }
    }
}

Note: After disabling the zmq security, no data loss was observed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions