Replies: 4 comments 4 replies
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: The error occurs because the Hello! Thanks for reaching out with this detailed issue. You've run into a subtle but important difference in how Python database drivers handle SSL connections. The root cause of the While the To fix this, you can import the import ssl
from fastapi import FastAPI
from google.adk.cli.fast_api import get_fast_api_app
host='<host>'
user='<user>'
password='<password>'
database='<db-name>'
ssl_key=r"db_client-key.pem"
ssl_cert=r"db_client-cert.pem"
ssl_ca=r"db_server-ca.pem"
SESSION_SERVICE_URI = f"mysql+aiomysql://{user}:{password}@{host}/{database}"
# 1. Create the SSL context
ssl_context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=ssl_ca)
# 2. Load the client key and certificate
ssl_context.load_cert_chain(certfile=ssl_cert, keyfile=ssl_key)
# 3. (Optional) Set other properties from your original code
ssl_context.check_hostname = False
# Note: setting verify_mode to CERT_NONE is insecure and should be used with caution.
ssl_context.verify_mode = ssl.CERT_NONE
# 4. Pass the ssl_context object in connect_args
db_kwargs = {
"connect_args": {
"ssl": ssl_context
}
}
app: FastAPI = get_fast_api_app(
agents_dir=AGENT_DIR, # Make sure AGENT_DIR is defined
session_service_uri=SESSION_SERVICE_URI,
session_db_kwargs=db_kwargs,
allow_origins=ALLOWED_ORIGINS, # Make sure ALLOWED_ORIGINS is defined
web=SERVE_WEB_INTERFACE, # Make sure SERVE_WEB_INTERFACE is defined
)
# <----next lines of code----->By creating the Let us know if you have any other questions! |
Beta Was this translation helpful? Give feedback.
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: The error occurs because the Hello! Thank you for the detailed and well-documented issue report. Your analysis is correct—the difference in behavior stems from the different database drivers being used. The ADK's The core of the issue is that different drivers handle SSL parameters differently:
To resolve this, you need to create the Here is the corrected version of your code: import ssl
from fastapi import FastAPI
from google.adk.cli.fast_api import get_fast_api_app
host='<host>'
user='<user>'
password='<password>'
database='<db-name>'
ssl_key=r"db_client-key.pem"
ssl_cert=r"db_client-cert.pem"
ssl_ca=r"db_server-ca.pem"
SESSION_SERVICE_URI = f"mysql+aiomysql://{user}:{password}@{host}/{database}"
# Create an SSLContext object for aiomysql
# For more details on ssl context options, see: https://docs.python.org/3/library/ssl.html#ssl-contexts
ssl_context = ssl.create_default_context(cafile=ssl_ca)
ssl_context.load_cert_chain(certfile=ssl_cert, keyfile=ssl_key)
# The following options are based on your original dictionary.
# Please ensure these security settings are appropriate for your environment.
ssl_context.check_hostname = False
# Your original `verify_mode` was False. The equivalent for ssl.SSLContext
# is ssl.CERT_NONE, which disables certificate validation.
ssl_context.verify_mode = ssl.CERT_NONE
db_kwargs = {
"connect_args": {
"ssl": ssl_context # Pass the SSLContext object here
}
}
# Assuming AGENT_DIR, ALLOWED_ORIGINS, and SERVE_WEB_INTERFACE are defined elsewhere
app: FastAPI = get_fast_api_app(
agents_dir=AGENT_DIR,
session_service_uri=SESSION_SERVICE_URI,
session_db_kwargs=db_kwargs,
allow_origins=ALLOWED_ORIGINS,
web=SERVE_WEB_INTERFACE,
)
# ... rest of your application codeBy providing the Let us know if you have any other questions! [1] https://google.github.io/adk-docs/docs/sessions/session.html |
Beta Was this translation helpful? Give feedback.
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: The error occurs because the Hello! Thanks for the detailed issue report. Your analysis is correct—the difference in behavior stems from using two different database drivers: The traceback While some drivers like To resolve this, you can use Python's built-in import ssl
from fastapi import FastAPI
from google.adk.cli.fast_api import get_fast_api_app
# --- Your existing parameters ---
host='<host>'
user='<user>'
password='<password>'
database='<db-name>'
ssl_key=r"db_client-key.pem"
ssl_cert=r"db_client-cert.pem"
ssl_ca=r"db_server-ca.pem"
# 1. Create the SSLContext object
ssl_context = ssl.create_default_context(cafile=ssl_ca)
ssl_context.load_cert_chain(certfile=ssl_cert, keyfile=ssl_key)
# The following lines are based on your original dictionary.
ssl_context.check_hostname = False
# 'verify_mode' in your dict was False, which corresponds to CERT_NONE.
# NOTE: This is insecure and should be used with caution. For production,
# consider using ssl.CERT_REQUIRED.
ssl_context.verify_mode = ssl.CERT_NONE
# 2. Update db_kwargs to pass the SSLContext object
SESSION_SERVICE_URI = f"mysql+aiomysql://{user}:{password}@{host}/{database}"
db_kwargs = {
"connect_args": {
"ssl": ssl_context
}
}
# --- Your existing app creation code ---
# AGENT_DIR, ALLOWED_ORIGINS, SERVE_WEB_INTERFACE should be defined as before
app: FastAPI = get_fast_api_app(
agents_dir=AGENT_DIR,
session_service_uri=SESSION_SERVICE_URI,
session_db_kwargs=db_kwargs,
allow_origins=ALLOWED_ORIGINS,
web=SERVE_WEB_INTERFACE,
)
# <----next lines of code----->By pre-constructing the |
Beta Was this translation helpful? Give feedback.
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: The error occurs because the Hello! Thank you for the detailed and well-documented issue report. You've correctly identified the key difference: the behavior of This is not an inconsistency within ADK, but rather a difference in the requirements of the two database drivers. ADK simply passes the To fix this, you need to create an import ssl
from fastapi import FastAPI
from google.adk.cli.fast_api import get_fast_api_app
# --- Your existing variable definitions ---
host='<host>'
user='<user>'
password='<password>'
database='<db-name>'
ssl_key=r"db_client-key.pem"
ssl_cert=r"db_client-cert.pem"
ssl_ca=r"db_server-ca.pem"
AGENT_DIR = "./agents" # Example, please adjust
ALLOWED_ORIGINS = ["*"] # Example, please adjust
SERVE_WEB_INTERFACE = True # Example, please adjust
SESSION_SERVICE_URI = f"mysql+aiomysql://{user}:{password}@{host}/{database}"
# 1. Create the SSLContext object
ssl_context = ssl.create_default_context(cafile=ssl_ca)
ssl_context.load_cert_chain(certfile=ssl_cert, keyfile=ssl_key)
# If you want to disable hostname checking (as in your original code):
# ssl_context.check_hostname = False
# ssl_context.verify_mode = ssl.CERT_NONE
# 2. Pass the context object in connect_args
db_kwargs = {
"connect_args": {
"ssl": ssl_context
}
}
# 3. Create the app
app: FastAPI = get_fast_api_app(
agents_dir=AGENT_DIR,
session_service_uri=SESSION_SERVICE_URI,
session_db_kwargs=db_kwargs,
allow_origins=ALLOWED_ORIGINS,
web=SERVE_WEB_INTERFACE,
)
# <----next lines of code----->By creating the Let me know if you have any other questions! |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
As a part of deployment of agents on GKE, i am following the documentation as per the link:
https://google.github.io/adk-docs/deploy/gke/#code-files
When i open the ADK web UI and try to test the Agent, i get an error.
Here are my console logs:
Having said that, i am able to connect to the
DatabaseSessionServicewith the same Credentials as aboveWhy is this happening. With the same connection parameters to connect to the DB, I am able to successfully connect DB Session Service and not on FastAPI wrapper of ADK using get_fast_api_app?
I understand that the same DB engines:
mysql+aiomysqlandmysql+pymysqla are different. But isnt that an Inconsistency.Py: 3.13
google-adk: 1.21.0
Beta Was this translation helpful? Give feedback.
All reactions