AppOfflineError: Connection to server failed (error) - Running app outside hosted environment

Hi,
How are you?


The scenario:


  1. I developed a simple CRUD using the Anvil Editor in the hosted environment (and it runs fine)
  2. Cloned the app using GIT to the opensource server in an external VPS (the opensource Anvil server runs in Docker)
  3. Installed and run the app in a Docker Container

The behavior


The app starts running … but after a while, and before showing anything, it throws: AppOfflineError: Connection to server failed (error)


The context


The application runs fine when run in the hosted environment.

The application cloning, and running procedure is the same I’ve used for other applications, with the difference that the other applications do not connect to a database (and they work perfectly in the same setup)

Also I get this logs from the container:

[INFO anvil.app-server.tables] Migrating automatically…
[INFO anvil.app-server.tables] Migration complete.
[INFO anvil.core.server] HTTP Server running on port 3030
[INFO anvil.app-server.run] App URL: https://myserver.com
[INFO anvil.app-server.dispatch] Launching built-in downlink…
[INFO anvil.app-server.run] SMTP Server running on port 25
[INFO anvil.executors.downlink] Downlink client connected with spec {:runtime “python3-full”, :session_id “e1uY78HCCL5L41l0y2s6”}


The questions:


a. To which server is the error referring to?

  1. Anvil hosting server
  2. Postgres server inside Anvil Docker container
  3. Other server I’m not aware of

b. Could the problem be related to the fact that I don’t have a paid version yet and therefore I don’t have a “python3-full”, environment?

c. Will it work once I have the paid version?

Thank you very much!!!
Warm regards
Ricardo

P.S. If anyone believes sharing the application will help please let me know and I’ll be glad to do it. I didn’t do it now because the application works well and this looks more like a server/configuration/policies problem.

Are you running the JVM in your container? A large part of the app server is written in clojure.

Also see the development of Amoni, for some docker hurdles that have already been overcome.

1 Like

Hi Ian,
Thank you for your answer!

I don’t know how to answer your question about the jvm, sorry, I probably know too little at this point.
I’m using the opensource image as provided for creating the container.

After taking a quick look at amoni, I believe it provides tools to develop outside the hosted Anvil editor, and what I wanted to do is to run something developed in the hosted editor, from the outside (in the opensource server), but pointing to the hosted tables.
I don’t know if I made it a bit more clear, or not?

Thank you!!
Warm regards
Ricardo

Amoni is basically a wrapper over various docker commands and config to make life easier if you’re working locally.

You could either just use it to run your app or take a look at the docker/docker compose config it uses and and copy them (with the appropriate licence text and attribution).

Not sure what you mean by:

If you mean app tables hosted at anvil.works, you’ll need to use uplink. If you just mean app tables locally, amoni creates a separate docker container for postgresql and configures the app server to use it.

1 Like

Hi Owen,
I hope you are fine!
Thank you very much for your answer!! and also the clarification about what amoni does.

Yes, that is exactly what I mean; I want to run the application in the opensource server but point to the app tables I’ve already created in anvil.works hosting.
I’m not familiar with uplinks yet, so I will have to study them and see how is that you can achieve this access from your not-hosted app.

Thanks again!
Warm regards!!
Ricardo

P.S. If you happen to have an example on how to do this with uplinks it will really help me speed up my path in this matter. Thank you!!

If you haven’t tried anvil-uplink yet, you should really look into it.

I don’t know for what exact reason you want to run the open-source server on an external machine, but if the only reason is to be able to control the external machines resources or python libraries or to do or access something secure outside the Anvil.app hosted environment, then what you really want is anvil-uplink.

It lets you run any arbitrary scripts or code on another machine that can be accessed by your hosted app using a unique key to connect. Once connected your app has the ability to access any callable decorated function on your local machine using a normal anvil.server.call('your_fn_name').
(It also works in reverse, and the connected script can access your app_tables, if you give it permission)

It’s also very intuitive and not hard to use:

2 Likes

Hi Ian,
Thank you again for your extremely clear explanation!!
The reason is a combination of all the things you mentioned, and becoming prepared for doing the same thing in different ways according to the requirements of the moment.
I will definitely put uplinks in my next slot of “to learn” things.

Warm regards!!
Ricardo

1 Like