What I’m trying to do:
What I try is to call functions of an uplinked code, resident at the same machine with the anvil-app-server and Git_cloned app, from client.
What I’ve tried and what’s not working:
The calls work when the app operates in browser, but when I run it via the anvil-app-server, the uplink functions can’t be found by the client (NoServerFunctionError: No server function matching “xxxx_xxxx” has been registered). Checked the cases for this error in the forum, but did not find solution
I don’t know the basic principles of the app server and I guess the client is restricted to call server_modules only. I hope I’m wrong and will appreciate any advice how to resolve or work around this issue.
# This is the form of illustrative example:
class Form1(Form1Template):
def __init__(self, **properties):
self.init_components(**properties)
self.label_1.text = "Calling the server func hello()"
r = anvil.server.call("hello")
self.label_2.text = f"Received r = {r}"
def button_1_click(self, **event_args):
r = anvil.server.call("hello")
self.label_3.text += f"{r} " + ' '`
# This is an uplinked server func:
@anvil.server.callable
def hello():
print("Uplink REACHED")
return("I'm HERE")
anvil.server.connect("server_75MALOC3BBRCRAYQGCXPOXHP-CSIPMK67RPV3EZ3Y")
while True:
if keyboard.is_pressed('p'):
print("Main is ending ... ")
time.sleep(0.1)
break
sys.exit(0)
This was the result:
Calling function ‘hello’ for app ‘Utest’ (ID server-osS83uiyshdxjg==)
Worker terminated for IDs set() (return code None)
[ERROR anvil.app-server.run] Error report from client code:
NoServerFunctionError: No server function matching “hello” has been registered
Traceback:
app/Utest/Form1/init.py:13
Okay, so from memory you have to add uplink-key “yourkey” to the command line when you launch the app-server and, also, you have to add the wss:// for your app to the method of your uplink connect in your local code…
Actually, I started the server by: anvil-app-server --app Utest --uplink-key server_75MALOC3BBRCRAYQGCXPOXHP-CSIPMK67RPV3EZ3Y. Is that what you suggest?
Regarding the wss:// I’ve never done this. Would you, please, recommend a link to read about how to
Sure. With amoni, they’re just docker containers, so you can run as many as you like. If they run simultaneously, you’d have to adjust the ports they listen on, but that’s about it.