1

I am trying to connect a client machine to a server mashine in different network using PYRO4 and Python 2.7

My server code is:

import Pyro4

class Thing(object):
    def method(self, arg):
        return arg*2

daemon=Pyro4.Daemon(port=9999,nathost="78.149.X.X", natport=5555)
uri=daemon.register(Thing(),"gameServer")  # register Thing() as a Pyro object
print "Ready. Object uri =", uri
daemon.requestLoop()

and the client code is:

import Pyro4

server = Pyro4.Proxy("PYRO:gameServer@78.149.X.X:5555")
print server.method(6)

However, when I ran the server, I got this error:

CommunicationError: cannot connect: [Errno 10061] No connection could be made because the target machine actively refused it

I am searching since 8 hours to fix this issue but it seems it will not be fixed forever. Please if anybody know the solution please help me.

NOTE: 1. I am rannig the server behind a router, so I forworded the port 5555 to my private IP address. Also, I tested the port by an online service and its opend correctly.

  1. I closed the firewall and the antivirus software.

1 Answers1

1

Have you tried all the suggestions mentioned in the manual?

Your daemon simply is not accessible on the address that you think it is. Perhaps you need to add an appropriate binding host to the daemon constructor call, to bind it on the network interface that is accessible from the outside.

Also try to eliminate possible causes one by one and see which one is the culprit. For instance, have you tried to run it without the router in between?

Irmen de Jong
  • 2,739
  • 1
  • 14
  • 26
  • I checked some of the tips in the manual. for example, some times ping and telnet working fine and some times not, I am using pickle as a serializer. Also, I saw this information in [Pyro behind a NAT router/firewall](https://pythonhosted.org/Pyro4/tipstricks.html#nat-router) in the manual about how to make Pyro working behind a router and I used the same daemon example in that page. Sorry my engilsh is not good, thank you for your help I hope to make the connection asap becouse I am studying MSc computer science and pyro is one of the requirments in my final project. – Wissam Al-Kindy Jul 14 '15 at 09:35
  • I will try to run it without router. – Wissam Al-Kindy Jul 14 '15 at 09:36
  • I tried to connect without router but got the same error. could you explain "Perhaps you need to add an appropriate binding host to the daemon constructor call", like what another host and port? – Wissam Al-Kindy Jul 18 '15 at 10:04
  • The daemon binds on the default network interface, this is the ip address it prints. If you can't connect to that precise address, it may be because it is not accessible from the other machine. In that case you need to specify a host argument to the daemon's constructor where you give it the hostname or ip address of another interface that *is* reachable. What bothers me is that you write "sometimes ping and telnet work and sometimes not" this tells me you have some weird unreliable network connectivity going on in your setup – Irmen de Jong Jul 22 '15 at 18:03