Server function not registered from outside link

I have a small bit of code running on another machine which needs to access an Anvil app. I am running in a virtual environment on the outside machine that has only anvil-uplink and nothing else, It fails on the first such call:

(wongpool) 23:23 ~/wongpool $ python anviltask.py
Connecting to wss://anvil.works/uplink
Anvil websocket open
Connected to "Default environment (published)" as SERVER
Traceback (most recent call last):
  File "/home/jfalk/.virtualenvs/wongpool/lib/python3.7/site-packages/anvil/server.py", line 306, in call
    return _do_call(args, kwargs, fn_name=fn_name)
  File "/home/jfalk/.virtualenvs/wongpool/lib/python3.7/site-packages/anvil/server.py", line 298, in _do_call
    return _threaded_server.do_call(args, kwargs, fn_name=fn_name, live_object=live_object)
  File "/home/jfalk/.virtualenvs/wongpool/lib/python3.7/site-packages/anvil/_threaded_server.py", line 403, in do_call
    raise _server._deserialise_exception(r["error"])
anvil._server.NoServerFunctionError: 'No server function matching "player_list" has been registered'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "anviltask.py", line 71, in <module>
    update_text = update()
  File "anviltask.py", line 45, in update
    h = get_all_homers(d)
  File "anviltask.py", line 6, in get_all_homers
    result = anvil.server.call('player_list')
  File "/home/jfalk/.virtualenvs/wongpool/lib/python3.7/site-packages/anvil/server.py", line 309, in call
    raise _server._deserialise_exception(e.error_obj)
anvil._server.NoServerFunctionError: 'No server function matching "player_list" has 
been registered
(wongpool) 23:26 ~/wongpool $ 

Note that the same function runs fine in the Anvil cloud.

Hard to tell without seeing the code, but my guess is that you haven’t decorated the functions with

@anvil.server.callable

or you are not calling them with

anvil.server.call()

Nope. The code works fine within the app, and it’s the same code, so I don’t think either of these is possible. Just to be complete, the function itself is about as simple as it gets:

In the server module:

@anvil.server.callable
def player_list():
   return app_tables.players.search()

And in the code running on the foreign computer (as you see in the error message)

result = anvil.server.call('player_list')

By any chance, is the app “published”? If so, did you add the function after you last published?

If so, it could be you are connecting to the non-dev uplink key and the function is still in the dev branch of your code.

If not, then I’m not sure …

3 Likes

That did the trick! I changed the key to the dev uplink key and it worked.

That leads to an entirely different confusion on my part: when I change the code, then the public link reflects those changes. So I guess I don’t really understand the difference… time to peruse the docs (and the forum) once again. Thanks @david.wylie

1 Like

It turned out, @david.wylie, that my confusion here used to be your confusion. Development vs Published I agree with your confusion from back then.

1 Like

A post was split to a new topic: No server function