Hello,
I am not really familiar with how the Anvil server works in terms of authentication and communication between server, uplink, and client. However, I will try to explain the issue as much as I can, please excuse my English:
1- I created a simple ‘Hello World’ app on anvil online editor, then I tested it and it was working perfectly.
2- I used the external uplink feature to keep my server script on a remote server, and again everything was working like a charm, here is the code:
from ._anvil_designer import Form1Template
from anvil import *
import anvil.server
class Form1(Form1Template):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
def button_1_click(self, **event_args):
"""This method is called when the button is clicked"""
self.message_label.text = anvil.server.call('get_name', self.name_box.text)
pass
def text_box_3_pressed_enter(self, **event_args):
"""This method is called when the user presses Enter in this text box"""
pass
def sum_click(self, **event_args):
"""This method is called when the button is clicked"""
self.result.text = anvil.server.call('add_nums', self.num1.text, self.num2.text)
pass
and here is the server script which is running on the external uplink:
import anvil.server
anvil.server.connect("UPLINK DERIVED FROM ANVIL ONLINE")
@anvil.server.callable
def get_name(name):
response = "Hello from the server, %s!" % name
return response
@anvil.server.callable
def add_nums(num1,num2):
result = int(num1)+int(num2)
return result
anvil.server.wait_forever()
3- Now, I tried to clone my app which is on Anvil online via git so I can host it completely from my external server:
git clone ssh://bla@bla.bla@anvil.works:2222/RN35GHXNR4UHW77W.git Hello_World
anvil-app-server --app Hello_World --origin https://somewhere.domain.com
So far so good, the app was loading normally on the browser via the external URL
4- Finally, when I input some data and press the button I end up with this ugly error:
Code Sample:
[ERROR anvil.app-server.run] Error report from client code:
NoServerFunctionError: No server function matching "get_name" has been registered
Traceback:
app/Hello_World/Form1/__init__.py:15
^CTraceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/melsayeh/env/lib/python3.8/site-packages/anvil_downlink_host/run.py", line 4, in <module>
anvil_downlink_host.run_downlink_host()
File "/home/melsayeh/env/lib/python3.8/site-packages/anvil_downlink_host/__init__.py", line 474, in run_downlink_host
time.sleep(5)
I am pretty sure I am missing something really obvious even though I spent a long time reading through Anvil documentation. Hope to find some guidance here.
Thanks!
Clone link:
share a copy of your app