1

I tried to connect my PUB-client ( uses pyzmq version 19.0.0 ) with server via udp://:

context = zmq.Context()
socket = context.socket( zmq.PUB )
socket.connect( "udp://127.0.0.1:34567" )

but the code throws always an error: zmq.error.ZMQError: The protocol is not compatible with the socket type

I have tried all socket types, like: REQ, REP, PUB, SUB, PAIR, DEALER, ROUTER, PULL, PUSH

Do you know what's the problem?

user3666197
  • 1
  • 6
  • 50
  • 92
user2973395
  • 37
  • 1
  • 5

2 Answers2

1

ZeroMQ does support both :
both the UDP:// and {PGM|EPGM}:// transport-classes

Examples of { PGM | EPGM } :

// Connecting to the multicast address 239.192.1.1, port 5555,
// using the first Ethernet network interface on Linux
// and the Encapsulated PGM protocol

rc = zmq_connect( socket,           "epgm://eth0;239.192.1.1:5555" );
assert ( rc == 0 and "ASSERT FAILED: epgm://eth0;239.192.1.1:5555 ............. " );

// Connecting to the multicast address 239.192.1.1, port 5555,
// using the network interface with the address 192.168.1.1
// and the standard PGM protocol

rc = zmq_connect(socket,            "pgm://192.168.1.1;239.192.1.1:5555" );
assert ( rc == 0 and "ASSERT FAILED: pgm://192.168.1.1;239.192.1.1:5555 ........" );

The pgm:// and epgm:// transports can only be used with the ZMQ_PUB and ZMQ_SUB socket types.


UDP:// transport can only be used with the ZMQ_RADIO and ZMQ_DISH socket types.

Examples of UDP .bind(), .connect()-s are analogous :

// Unicast - UDP port 5555 on all available interfaces
rc = zmq_bind( dish,                "udp://*:5555" );
assert ( rc == 0 and "ASSERT FAILED: udp://*:5555 ............. " );

// Unicast - UDP port 5555 on the local loop-back interface
rc = zmq_bind( dish,                "udp://127.0.0.1:5555" );
assert ( rc == 0 and "ASSERT FAILED: udp://127.0.0.1:5555 ............. " );

// Unicast - UDP port 5555 on interface eth1
rc = zmq_bind( dish,                "udp://eth1:5555" );
assert ( rc == 0 and "ASSERT FAILED: udp://eth1:5555 ............. " );

// Multicast - UDP port 5555 on a Multicast address
rc = zmq_bind( dish,                "udp://239.0.0.1:5555" );
assert ( rc == 0 and "ASSERT FAILED: udp://239.0.0.1:5555 ............. " );

// Same as above but joining only on interface eth0
rc = zmq_bind( dish,                "udp://eth0;239.0.0.1:5555" );
assert ( rc == 0 and "ASSERT FAILED: udp://eth0;239.0.0.1:5555 ............. " );

// Same as above using IPv6 multicast
rc = zmq_bind( dish,                "udp://eth0;[ff02::1]:5555" );
assert ( rc == 0 and "ASSERT FAILED: udp://eth0;[ff02::1]:5555 ............. " );

The Best Next Step :

Now review the scope and the state of the pyzmq-19.0.0 implementation of the native-API ( be it 4.3.2+ or older ).

user3666197
  • 1
  • 6
  • 50
  • 92
0

zmq does not generally use udp sockets because they are unreliable, the only udp sockets are dish and radio but they are experimental, you can read more here
relevant quote:

UDP transport can only be used with the ZMQ_RADIO and ZMQ_DISH socket types.

Nullman
  • 4,179
  • 2
  • 14
  • 30
  • 2
    context = zmq.Context() socket = context.socket(zmq.ZMQ_RADIO ) ZMQ_RADIO and ZMQ_DISH don't exist: AttributeError: module 'zmq' has no attribute 'ZMQ_RADIO' – user2973395 Mar 10 '20 at 10:20
  • like i said, its experimental. you will have to put in extra work for that, [here](https://github.com/zeromq/pyzmq/issues/911#issuecomment-322996020) is a good starting point and [here](https://pyzmq.readthedocs.io/en/latest/draft.html) is more info in docs – Nullman Mar 10 '20 at 11:22