-->

ZMQError: Cannot assign requested address

2020-07-18 06:06发布

问题:

I'm using zeromq to develop a dynamic application which operate like upnp protocol( autoconfiguration and auto-discovery of equipment on a living room). To do it so, i use zeromq to distribute messages, my problem is that when i create a socket and binding on a adress "169.254.1.0 through 169.254.254.255", I receive a error messages like this: ZMQError: Cannot assign requested address.

I've tried to figure out why by changing the address by local adress (127.0.0.1),and it's works !!. The problem is that i'm implementing autoip, it's means that i'm oblliged to use the adresse on range 169.254.1.0 through 169.254.254.255.

Thanks in advance for your help!

回答1:

After you bring the interface up, you need to get its IP address and then bind on that. Alternatively you may be able to bind on "*", meaning all interfaces.



回答2:

I got this error, too... and I realized I had the wrong idea of who was connecting to whom in the PUB/SUB model.

This was working: Host A as the ZMQ PUB, and could easily connect with Host A as the ZMQ SUB.

Then I tried to set up Host B as the SUB, and have Host A "send" to that... and I kept getting this error. After all don't you need to tell the PUB where to send the data?

No! Host A as the PUB should still bind to IP_ANY (0.0.0.0); it is Host B as the SUB who has to be configured with the address of Host A.

Once I got that straight in my code (and in my head), I was up and running.



标签: zeromq