question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ZBeacon Doesn't Ignore It's Own Beacons

See original GitHub issue

The following code will every second print out:

/192.168.1.109
127.0.1.1
ZRE�

Ie. its own beacon, despite this version of the constructor telling it to ignore its own beacons:

import org.zeromq.ZMQ;
import org.zeromq.ZMQ.Socket;
import org.zeromq.ZContext;
import org.zeromq.ZBeacon;
import org.zeromq.ZBeacon.Listener;
import java.net.InetAddress;

public class zmq_test
{
    public static void main( String[] args )
    {
        try{
           zmq_test a = new zmq_test();
           a.run();
        }
        catch(Exception e){}
    }

    private Remote remote;
    private Thread service;

    public void run() {
        remote = new Remote();
        service = new Thread(remote);
        service.start();
    }

    public class Remote implements Runnable {
        private volatile boolean running = true;
        public Remote() {  }

        private byte[] make_beacon_message(int port) {
            //zre protocol
            byte msg[] = new byte[] { 'Z', 'R', 'E', '\1', '\0', '\0', '\0', '\0', '\0', '\0',
                                      '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
                                      (byte)((port >> 8) & 0xFF), (byte)(port & 0xFF) };
            return msg;
        }

        public void abort() {
            running = false;
        }

        public void run() {
            //random port in suggested IANA range
            ZContext context = new ZContext();
            Socket service = context.createSocket(ZMQ.REP);
            int port = service.bindToRandomPort("tcp://*", 49152, 65535);
            //beacon for service discovery on reserved zre discovery port
            byte[] msg = make_beacon_message(port);
            ZBeacon beacon = new ZBeacon("255.255.255.255", 5670, msg, true);
            beacon.setPrefix(new byte[]{'Z', 'R', 'E', 0x01});
            beacon.setListener(new Listener() {
                @Override
                public void onBeacon(InetAddress sender, byte[] beacon) {
                    System.out.println(sender.toString());
                    try{
                        System.out.println(InetAddress.getLocalHost().getHostAddress());}
                    catch(Exception e){}
                    System.out.println(new String(beacon));
                }
            });
            beacon.start();
            //listen for requests
            while(running) {
                byte[] bytes = service.recv();
                if(bytes != null) {
                    //TODO:
                }
            }
            try { beacon.stop(); } catch (Exception e){}
            service.close();
            context.close();
        }
    }

}

Indeed stepping through with the debugger one can see that this line:

https://github.com/zeromq/jeromq/blob/master/src/main/java/org/zeromq/ZBeacon.java#L211

Turns out to be false because usually you’ll get something like 127.0.0.1 out of InetAddress.getLocalHost().getHostAddress() where as the senderAddress.getHostAddress() will be what you might see in ifconfig ie. 192.168.1.107 or something.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
daveyarwoodcommented, Sep 18, 2017

Alright – closing for now. We can always reopen this issue if it is found to still be a problem now.

0reactions
kevinkreisercommented, Sep 18, 2017

@daveyarwood im happy if you want to close this issue. i worked around it and havent tried it without the work around since. its very possible that at this point i no longer need the work around so please dont hold the issue open on my account!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Boosting Wi-Fi Performance with Beacon and Beacon Interval
See how beacons and beacon interval can significantly impact your Wi-Fi performance in our blog on 7SIGNAL's Sapphire Wi-Fi Performance Management system.
Read more >
Beacon Functions: Keep Away vs. Ignore Fences
The Keep Away function is the 'original' Halo Beacon functionality. It can be used to keep your dog out of unwanted or unsafe...
Read more >
HTTP Beacon and HTTPS Beacon - Cobalt Strike - Fortra
Check the Ignore proxy settings; use direct connection box to force Beacon to attempt its HTTP and HTTPS requests without going through a...
Read more >
Beacon - New inventory Connection error - Flexera Community
If we ignore it, we can not see the drop down list for inventory sources, if we cancel it, the beacon application is...
Read more >
Beacon Analysis - The Key to Cyber Threat Hunting
Beaconing is a communication characteristic. It'is not good or evil, but just a way of describing the communication flow. While beaconing is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found