Your session has timed out. Please refresh the page to continue

Hello dear FORUMERS,

After leaving my app’s page for long it is require the Refresh

“Your session has timed out. Please refresh the page to continue.”

This happen even after the restarting of computer

It was working well before but now it is constantly asking to refresh - only deleting cookies of web browser solving this situation.

Can someone suggest what we need to do? Or it is internal bug?

My browser is Safari but same happen on Chrome as well

I just started getting into Anvil and am getting that error message every time I run my code.
My python code is on the Jupyter notebook on my computer. When I run my Anvil code, it only gives me the session time out message above. Have you been able to get your Anvil code to run at all? If so, where is your Python code? Is it on your home computer? Or somewhere else?

Last I checked, Anvil code is Python code :wink:.

Forum volunteers will need to know more, about your specific situation, before they can begin to guess where the problem lies.

Check out the “how to ask a good question” post for tips on how to help us help you.

1 Like

Sorry for the confusion. What I meant to say is that for Anvil to work, do I need to load my Python code from my Jupyter notebook onto Anvil somewhere to keep it available? What happens when my computer is shut down or inactive? Does that mean that others can’t access my webapp? Just not clear how it works. From Mereddyd’s YT video, it seemed like somehow the functionality would be retained in the cloud. Please excuse – I’m new and still trying to understand how this system works.

I’ll try to clear that up.

There are just a few categories of Python code involved in an Anvil App.

  1. Client-side code. This runs in each end-user’s browser, and runs the visual components they see. Each browser tab gets its own running copy of this code, and its own block of memory for the code’s variables.
  2. Server-side code. This runs on Anvil’s servers, “in the cloud”. It usually runs intermittently, i.e., on demand (function call) from Client-side code, from emails received, or from web-service requests. (Little to no long-term memory, but a database is available.) You can establish “Background tasks”, to run on whatever schedule you set in the IDE. You can add third-party Python packages to Server-side code.

A given App will consist of Client and/or Server code. Anvil keeps its own copy of this code, which you can edit and test using Anvil’s web-based IDE.

  1. Uplinked code. This runs on your own computer(s), but connects to your Anvil App via the Internet. It can run in a Jupyter notebook, or any other Python program. An Uplink program may be set to wait and respond to function calls from Client or Server code, or from other Uplink programs.

Uplinked code is optional. It’s often used to access resources that Anvil’s servers can’t (or shouldn’t) know how to reach directly.

In order to be able to respond to requests (function calls) from other code, your Uplink programs must stay running, on whatever computers you control. How you do that is up to you. Anvil does not keep a copy of this code.

The part of your App that you’ve coded in your computer’s Uplink program won’t be running, so it can’t “hear” any requests from elsewhere, and can’t respond. The rest of it will run just fine.

I hope this helps!

1 Like

Thanks for the ciarification.
Yes, sure enough, once I shut down my Notebook, my webapp was no longer functioning. So a Jupyter notebook needs to stay open all the time. I can’t leave an open notebook running like that. Even Google Colab closes an inactive session after a few minutes.
So this definitely limits the usability of Anvil. What have other people done?

You’ve connected Anvil to code running on a third party machine, then powered down that machine. The expected outcome is that Anvil will no longer be able to connect to the third party machine that’s been shut down (this isn’t a limitation of Anvil).

You can choose to move the code in your Jupyter notebook to Anvil server functions, or run it on a persistent third party server.

1 Like

OK, but I see that persistent servers on Anvil are available starting with a business acct priced at $299 /mo, which I suspect is not aimed at the student or general hobbyist. I’m simply not aware of any third-party persistent servers that let you keep a Jupyter notebook open. Would be curious if anyone else knew of any more affordable ones. I was hoping to have this available for a student project, but I’d have to have my instructor call me before accessing the webapp, so I can fire up my notebook and have it ready. That’s not going to work.

That’s not what he meant. That “persistent server” is something else entirely. You can write server code in Anvil that is available 24/7 on a free Anvil account.

1 Like

You can do that with a cheap (few dollars a month) VPS account available at any of a variety of hosting companies (I use A2), but I suspect that may be more than you want to get involved with for a 1-off student project. You can Google something along the lines of ‘run Jupyter notebook over SSH’, if that’s a direction you want to go.

To build an Anvil app, you typically write Python code in Anvil server functions, which get called from front-end Anvil client code (a subset of Python geared towards interacting with UI widgets). As jshaffstall noted, you can do that with a free Anvil account. Depending on how much time you’re devoting to building a web app, you can move the code you’re currently running in your Jupiter notebook, to Anvil Server functions.

1 Like

I see.

So I would like to store my ML trained model in the server code repo, but the model needs to load trained weights, which means I need disk space to store these, since I can’t load it from a URL. Which means a personal acct (I think). I hesitate to commit to a paid acct unless I can be certain that what I want will actually work.

The data files service is just a wrapper that makes it easier to store files in data tables. You can do everything you need straight from data tables.

The sticking point is going to be that on a free Anvil account you only have access to a standard set of Python libraries. You won’t be able to import anything different than the standard set, and I imagine you’re probably using some libraries for what you’re doing.

2 Likes

From this, it sounds like you’ve already built an Anvil app that’s connecting to your Jupyter notebook via uplink, and you just need to run the Jupyter notebook on a machine that’s always on. VPS is the cheapest way to do that commercially. If you don’t want to spend any money to get a single school project started, perhaps you can find a resource at your university, or a friend/family member that can provide an always-on machine where you can run your Jupyter notebook.

Also, your professor could potentially request access to Anvil education accounts, if he/she wants to use Anvil in class. That would get you past some of the limitations of the free Anvil hosted offerings (which would be helpful for you and your classmates to learn how to implement more of your projects’ code, data, libraries, etc. directly in Anvil, without any cost while you’re in school).

1 Like

Have you seen the Deploy tutorials here? Anvil | Data Science Tutorials

1 Like

Thanks for the heads-up. I have a VPS account at Dreamhost, but have not seen that they would offer Jupyter notebook hosting. I will inquire about that. I could move my model to an Anvil server, but it’s a trained model, and I would need to load checkpoint weights, which requires a personal account so I could store those items as well as the Python code. I haven’t decided if I want to go that route, but now that I have a sense of what to do (and because of the great one-on-one support you and Jay have provided), I am leaning that way. As I said, this is new ground for me, so apologies for all the newbie questions.

1 Like

I took a very brief look a Dreamhost’s VPS offerings, and it looks like you should be able to run anything you want there - they appear to provide root access to typical Linux distributions (and they even mentioned Windows). Most likely, you just need to learn to use SSH and be able to configure all your requirements on the command line, and you should be able to install your Python environment and jupyter notebook there (and you’d most likely even be able to run anvil-app-server on that account :sunglasses:)

OK, I signed up for a Personal plan, and moved the relevant parts of my Jupyter notebook code to the server code section. I found out I needed to install Python 3 and tensorflow, so I did that. I uploaded my checkpoint files. But now when I run the code, the image component in Form1 can no longer “see” the image file that I upload, and the self.image_1 can no longer see its event handler. I get another arcane error message saying "anvil.server.RuntimeUnavailableError: Could not launch server runtime - image build failed." I stared at my code, checked the forum for anything similar, but am coming up blank. I’m sure it’s a simple problem, but I’m stumped.

Are you able to see my code and point me in the right direction? Thanks.

How are you supplying the image source to your image widget (anvil media object from URLMedia(), uploaded with fileloader, from a data table, uploaded to assets (_/theme/…), etc.)?

Please explain what you mean by ‘see its event handler’. Do you have one of the mouse_* events set for the image widget, and have you written a method for that event handler?

We are community members (not Anvil employees), so we don’t have access to your code. You can post a clone link of your app if you’d like to share it publicly.

2 Likes

The image is supplied with the Upload widget. The app worked fine in the past, when the Jupyter code was located on my own computer. But now, when I upload an image, I get this error message:
"No method "image_1_show" in form Form1: cannot set the 'show' event handler of self.image_1."
As to the last point, someone previously requested permission to view my code, so I thought it was possible. Sorry for the confusion.

As before, I am including the @anvil.server.callable statement in my server code, but I feel that I am missing some step that tells my form to look to the Anvil server instead of a remote Jupyter notebook.