问题
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.
- I closed the firewall and the antivirus software.
回答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?
来源:https://stackoverflow.com/questions/31372515/pyro4-errno-10061-connection-refused