1

I am using Pyro4 to make a remote connection between a raspberry and a computer. I've tested the code local on my computer. But now I want to use it on the raspberry. Only problem the target machine refused it. Nameserver is set, I can ask for the metadata, client is not giving any error.

Server code:

daemon = Pyro4.core.Daemon("192.168.0.199")
Pyro4.config.HOST = "192.168.0.199"
ns = Pyro4.locateNS()
print ns.lookup("client", return_metadata=True) #this works
callback = MainController()
daemon.register(callback)
vc2 = Pyro4.core.Proxy("PYRONAME:client@192.168.0.199:12345")

Client code:

ns = Pyro4.locateNS()
Pyro4.config.HOST = "192.168.0.199"
uri = daemon.register(VehicleController)
ns.register("client@192.168.0.199:12345", uri)
print "Connection set!"
daemon.requestLoop()

Firewall is also off.

Thanks

Tom
  • 115
  • 1
  • 7

2 Answers2

1

The main issue is that the server never runs the daemon request loop and so cannot respond to requests.

But there are a lot of issues with the code as shown:

  • it is not complete.
  • you're mixing up server and client responsibilities; why is the client running a deamon? That's the server's job.
  • you're registering an object with a logical name that appears to be a physical one. That's not how the name server works.
  • you're registering things in both the client and server.
  • the server never runs the request loop of the daemon it creates.
  • what is that 'vc2' proxy doing in the server? Clients are supposed to create proxies to server objects.
  • it's generally best to set Pyro's config variables before doing anything else, this way you don't have to repeat yourself with the IP address the daemon binds on.

All in all you seem to be confused about various core concepts of Pyro. Getting a better understanding (have you worked through the tutorial chapter of the manual?) and fixing the code accordingly will likely resolve your issue.

Irmen de Jong
  • 2,739
  • 1
  • 14
  • 26
  • Thanks for you're answer. I'm mixing up server and client because I'm using a callback function (references to the callback example at your github). – Tom Oct 21 '16 at 14:51
  • I'll take a look to the manual again, but the whole code works when I run it local. Thanks – Tom Oct 21 '16 at 14:52
0

Okay, got some more info

I can connect when I edit my Pyro4 Core URL from obj_ x @0.0.0.0: x to obj_ x @192.168.0.199: x and connect manually. So I guess there is something wrong with the way I register the address to the nameserver.

I'll keep you in touch

Tom

Tom
  • 115
  • 1
  • 7
  • If your daemon binds on 0.0.0.0 and you register objects in that deamon with the nameserver, you may indeed run into trouble. Clients will retrieve 0.0.0.0 as the address from the nameserver and that is very probably not the address of your actual server machine. You'll have to change the address the daemon binds on. See https://pythonhosted.org/Pyro4/servercode.html#network-adapter-binding-and-localhost – Irmen de Jong Oct 24 '16 at 21:08