Can't connect to Google Colab Workbook

Trying to connect to Google Colab workbook and keep getting error. Code snippets are below. I’ve read that the code cell needs to be running but I think it is running as the animation on the side of the code cell is turning.

PLEASE SEND HELP!

Colab code:

Anvil code:

from ._anvil_designer import Form1Template
from anvil import *
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
import anvil.server

class Form1(Form1Template):

def init(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)

# Any code you write here will run when the form opens.

def button_1_click(self, **event_args):
“”“This method is called when the button is clicked”""
TeeTimes = anvil.server.call(‘PythonTeeTimes’)
pass

Anvil error:

RuntimeError: Connection to server failed (error) at [Form1, line 18]

[An internal error has occurred]

By publishing your uplink key, you are allowing anyone to gain full access to your app. I suggest you refresh that key quickly.

3 Likes

Right. Thanks. I have since updated the uplink key so I think that should fix it.

1 Like

Sorry Owen, did you have any idea on where my error is?

Sorry, no. I’ve never used Google colab.

1 Like

Hi @d_finkbeiner, and welcome to the Forum!

It looks like your app is having trouble reaching the Anvil servers (ie this isn’t actually a problem with the Uplink at all!). That error indicates that your browser-side code can’t make its websocket connection to make anvil.server.call()s.

We sometimes see this as a result of particularly restrictive work or school firewalls that block websockets – where are you testing this from? Alternatively, some ad blockers don’t like us – are you using an ad blocking extension? (While we’re at it, which browser are you using?)

Hi, thanks for your reply! Ah, that could definitely be it. I am working on my work computer and I have had connection issues in the past due to the firewalls. I will try and establish the connection on my personal computer later today and see if that fixes the issue.

I am/was using Chrome.

Thanks again!

1 Like

Sorry, one question. My code is saying the connection is made though, can the firewall still be the issue?

The Uplink code is connecting fine. The Client code (in your web browser) is failing to connect to Anvil.

I have had this issue in my organization, In order to get the browser client code to work for standard users, my IT administrator had to whitelist anvil.app in the work firewall.

My development PC has a whitelisted static IP, so of course it worked fine for me until I gave people the go-live version which promptly did not work for anyone! :man_facepalming:

So if:

I would definitely look in that direction first.

Thanks for the reply. Can I ask what you mean by this? I’ve seen reference to the connection not working when in development vs published and I’m not clear on it.

Only that the firewall for my company network is whitelist only for regular users, meaning the IT admin has to explicitly approve web addresses. (The default for all addresses is blocked unless approved)
Most firewalls come pre-loaded with a list of ‘normal’ sites like google, yahoo, msn, etc.

The website anvil.app was not on this pre-loaded ‘normal everyday use’ list, so my administrator had to add it.

This is unrelated to the developer / published versions, the computer I work on has unrestricted use of the internet for development purposes, so I did not have any anvil.app web-browser client use problems, but everyone I developed the app for at my company did. (Until this was fixed)

Ah, makes sense. Thanks for the detailed response.