0

I am able to have c# (client) and python (server) talk to each other by using a simple request-reply. However, I want my web application built on c# asp.net to be stable and need more clients and servers, so I tried connecting c# and python using the Router-Dealer Proxy with python.

I tried running the proxy python script first, then running c# (client), then python (server). However, when I run the python (server), it gives me an "Address in use" error message.

Am I running them in a wrong order OR is there something wrong with the proxy python script (shown below)?

5602 = c# client

5603 = python server

def main():

context = zmq.Context()

# Socket facing clients
frontend = context.socket(zmq.ROUTER)
frontend.bind("tcp://*:5602")

# Socket facing services
backend  = context.socket(zmq.DEALER)
backend.bind("tcp://*:5603")

zmq.proxy(frontend, backend)

# We never get here…
frontend.close()
backend.close()
context.term()

if __name__ == "__main__":
main()
Oleole
  • 381
  • 4
  • 21

1 Answers1

0

I'm assuming your servers use bind, so the proxy should connect to them rather than also using bind.

Note: in zeromq the order of application startup doesn't matter so you can tell your proxy to connect to a server that doesn't yet exist, when the server is started the connection will be made.

David
  • 1,510
  • 14
  • 20
  • Change "bind' to "connect" in the proxy script? Do you think using "bind" in the python server script will matter? – Oleole Aug 17 '16 at 20:01
  • Only change the 2nd one. So Client [connect], Proxy (frontend) [bind], Proxy (backend) [connect], Server [ bind ] (i.e matching connect-bind pairs ) – David Aug 17 '16 at 20:04
  • When I try backend.connect it throws an "Invalid argument" error. Is it a correct syntax? – Oleole Aug 17 '16 at 20:16
  • Turn out that I have to "fully" write out the tcp address instead of using asteroid (*) when using backend.connect. Thanks so much for your help! – Oleole Aug 17 '16 at 20:25