What I’m trying to do:
Connect dev and published branch with two different backend server
In Backend server, I am using anvil.server.connect(“Key”) for published and anvil.server.connect(“Key-DEV”) for development purpose.
I am calling server method from frontend Anvil UI as :
try:
anvil.server.call(“Anvil_Get_Start_End_Date”,None)
except Exception as e:
print(“Problem connecting: %s” % e)
print(“caught an exception, now we can handle the problem in here”)
Anvil_Get_Start_End_Date is first hit when connected to backend server for both environment.
What I’ve tried and what’s not working:
What’s happening?
Dev is working fine both development UI and dev server are connecting fine and working as expected.
What’s not happening?
When trying to connect with the public link it connects published server but in UI loading happens and takes forever and no any error seen.
In UI:
After long time I got RuntimeError: Connection to server failed (1006)
In server log:
Connecting to wss://anvil.works/uplink
Anvil websocket open
Connected to “Default environment (published)” as SERVER
I tried to use exception but didn’t catch error.
Code Sample:
# code snippet
In Dev Server:
try:
anvil.server.connect("Key-Dev")
except Exception as e:
print("Problem connecting: %s" % e)
In Published Server:
try:
anvil.server.connect("Key")
except Exception as e:
print("Problem connecting: %s" % e)
Clone link:
share a copy of your app