No server function error on cloned app

What I’m trying to do:
My app was working just fine on anvil IDE. However, as soon as I take a clone to an external server running on python venv, I receive No server function matching “function” has been registered. even though the uplink shows connected. the server is supposed to run the app as well as the server code as well.

What I’ve tried and what’s not working:
I changed the uplink key but to no avail. Appreciate your help!

Code Sample:

# code snippet

import anvil.server
anvil.server.connect("UPLINK KEY")

@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()

Clone link:
share a copy of your app

Hi there,

Could you share a snippet of the server code you are trying to run in your Uplink script (don’t share the uplink Key though).

You may be able even to add it to the original question where it says “code snippet”. Either way, it should help.

Hi,

Thanks for your reply. I have amended the topic with a code snippet from the server.
As I mentioned, the app works just fine and communicate with the remote uplink when I run it on Anvil IDE, but when I clone the app to the server itself, it can’t communicate with the uplink as if the key is changing.

Could anyone help with this, please?

It seems the uplink key changes when the app is copied out to an external server rather than anvil cloud. Any idea how do I get my app to communicate with the uplink though?

You will need to generate your own uplink key for the app server and have your app code use the new key instead. See https://github.com/anvil-works/anvil-runtime for more information

Thanks a lot for the reply,

But I think I am missing something really important here since I am trying to run the app server on the uplink itself, so I am pointing to the URL as follows:
export DOWNLINK_SERVER=ws://127.0.0.1:3030/_/downlink
export DOWNLINK_KEY="[downlink_key]"

so that I can use this key as an uplink key on the app code. However, I receive a connection refused error when I execute (python -m anvil_downlink_host.run) means nothing listens to that port.

Not sure if I am following the right procedure though! Is there another way to generate an uplink key for my app server?

Uplink and downlink keys/code are for different purposes. Your Anvil server modules are run in the context of the downlink host (which is normally spawned by the app server). The opening post of this thread refers to uplink code which is typically used for functionality outside of the app server environment (e.g. IOT device control).
When launching the app server, you need to pass it your new uplink key using either the command line option --uplink-key KEY or via a YAML config file. The same key is then used in your uplink code.