Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing ipc:// to tcp:// python zmq (Windows)

I't trying to get a python application running on Windows and I get an ZMQError: Protocol not supported which is because ipc is not supported on windows. From what I have read the change from ipc to tcp protocol should be as easy as changing the string that is used in bind().

        master_addr = 'ipc://{0}/sailfish-master-{1}_{2}'.format(
                tempfile.gettempdir(), os.getpid(), subdomain.id)
        ipc_files.append(master_addr.replace('ipc://', ''))
        sock = ctx.socket(zmq.PAIR)
        sock.bind(master_addr)
        sockets.append(sock) 

If i change ipc:// to tcp:// I get ZMQError: Invalid argument so I guess it is not that simple. Could you walk me through the process of getting this fixed for windows, or tell me if I'm asking a stupid question.

You can see the full script https://github.com/sailfish-team/sailfish/blob/master/sailfish/master.py the code above is from line 250. SailfishCFD is a Python Lattice Boltzmann (LBM) simulation package for GPUs (CUDA, OpenCL)

Thank you very much!

like image 933
Dimitar Baldzhiev Avatar asked Nov 03 '14 10:11

Dimitar Baldzhiev


1 Answers

ZeroMQ is transport agnostic

That means, one may pass messages irrespective of what transport-class { inproc:// | ipc:// | tcp:// | pgm:// | epgm:// } is being used "under-the-hood".

That does not mean the same ( transport-specific ) addressing syntax will work in either case.

master_addr = 'ipc://{0}/sailfish-master-{1}_{2}'.format( tempfile.gettempdir(),
                                                          os.getpid(),
                                                          subdomain.id
                                                          )
sock.bind( master_addr )                                  # works on Linux/ipc
#   .bind( <<<tcp_addr>>> )                               # fails on "{0}{1}{2}".format-addressing"

Windows do not allow for using ipc: transport-class. Such a need-to-change will influence a bit wider scope of your source code, as there are some additional ipc-related assumptions on addressing.

As seen in:

addr         = "tcp://{0}".format( self._subdomain_addr_map[nbid] ) # tcp://<ip>:<port>?
addr         = "tcp://{0}".format( self._iface )                    # ref. #104 missing ":<port>" part!
summary_addr = 'tcp://127.0.0.1:{0}'.format( config._zmq_port )     # port free?

Start with:

framing the issue. Your code uses variable "fileName"-alike naming ( addressing ) for the IPC-pipes. There you start.

try:
     print                                   "DEBUG: Try to .bind() a ", master_addr
     sock.bind( master_addr )
     print                                   "     ==OK."

except ZMQError as Exc:
     print                                   "     ! FAILED:"
     # log & handle Exc details

except:
     print                                   "     ! FAILED: a non-ZMQ-related issue"
     # log & handle Exc details

Port#-s:

Be sure you do not command zmq.bind() on Windows to touch "priviliged" / already-used / firewall-"blocked" TCP-port#-s.

Having checked these system settings & having made zmq-call(s) syntax compatible with ZeroMQ API for tcp:// transport-class,

i.e.:

"tcp://<ip_address>:<port#>" # asString

or

"tcp://<aDnsResolvableHostNAME>:<port#>" # asString

you have it.

like image 166
user3666197 Avatar answered Sep 25 '22 18:09

user3666197