0

This code defines the services:

from nameko.rpc import rpc


class GreetingService:
    name = "greeting_service"

    @rpc
    def hello(self, name):
        return "Hello, {}!".format(name)
    
class MultiplyService:
    name = "multiply_service"
    
    @rpc
    def multiple(self,a,b):
        return str(int(a) * int(b))

I have the services running: enter image description here

I can open a nameko shell and access the microservice: enter image description here enter image description here

I want to access the microservice from another Python script. What am I missing? enter image description here

Progman
  • 16,827
  • 6
  • 33
  • 48
nicomp
  • 4,344
  • 4
  • 27
  • 60
  • 1
    [Please do not upload images of code/errors when asking a question.](https://meta.stackoverflow.com/q/285551) – Progman Jul 10 '22 at 10:38

1 Answers1

0

The n global is only available inside nameko shell.

To invoke an RPC from a script, you need to use the one of the "standalone" clients in nameko.standalone.rpc.

Example in the docs here https://nameko.readthedocs.io/en/stable/built_in_extensions.html#rpc

Matt
  • 2,153
  • 1
  • 18
  • 29