zeromq / pyzmq

PyZMQ: Python bindings for zeromq
http://zguide.zeromq.org/py:all
BSD 3-Clause "New" or "Revised" License
3.74k stars 636 forks source link

UDP Dish/Radio raises error: The protocol is not compatible with the socket type (addr='udp://localhost:5557') #2016

Closed u3Izx9ql7vW4 closed 3 months ago

u3Izx9ql7vW4 commented 3 months ago

According to the documentation(http://api.zeromq.org/4-2:zmq-udp), UDP is supported with Dish/Radio pattern. However when my server tried to bind to a localhost UDP address I got:

  File "/home/bob/program/symlink/utilities/sklutils/module_pubsub.py", line 33, in connect_udp_multicast_publisher
    client.bind(address)
  File "/home/bob/.local/lib/python3.11/site-packages/zmq/sugar/socket.py", line 311, in bind
    super().bind(addr)
  File "_zmq.py", line 917, in zmq.backend.cython._zmq.Socket.bind
  File "_zmq.py", line 179, in zmq.backend.cython._zmq._check_rc
zmq.error.ZMQError: The protocol is not compatible with the socket type (addr='udp://localhost:5557')

The snippet that generated the error is here:

ctx = zmq.Context()
client = ctx.socket(zmq.RADIO)
client.bind(address)

I found an issue issue https://github.com/zeromq/pyzmq/issues/911 from 2016 and ran the install script linked in the issue found at https://github.com/zeromq/pyzmq/blob/main/examples/draft/install.sh and also tried to run the following, as --install-options throws no such option: --install-option

pip install --upgrade --pre pyzmq --config-settings enable-drafts=1

but got:

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pyzmq in /home/bob/.local/lib/python3.11/site-packages (26.1.0)
minrk commented 3 months ago

I think the answer to your question is only DISH can bind to udp, RADIO can only connect.

I'm not sure where --config-settings enable-drafts=1 is coming from, since that's not a thing I'm aware of. The draft install script appears to work, though it could probably use some updates.

The last message is stating that you already have pyzmq, so there's nothing to do (pip doesn't care that you've asked for a different build, it only cares that the version is satisfied). Pip will only install packages if they don't already satisfy version requirements, so you'll need to either uninstall pyzmq or use an argument that forces reinstall.