I’m using GridDB Cloud with the official Python client to insert real-time IoT data into a time-series container.
The script runs continuously, but after a few hours I get a connection timeout and inserts stop working.
Code example:
import griddb_python as griddb
from datetime import datetime
factory = griddb.StoreFactory.get_instance()
store = factory.get_store(
notification_member='xxx.xxx.xxx.xxx:10001',
cluster_name='myCluster',
username='admin',
password='admin'
)
container = store.get_container("sensor_data")
while True:
row = ["sensor_1", datetime.now(), 22.5]
container.put(row) # <-- this fails after a few hours
Error message:
GSConnectionException: Connection timed out
What I want to know:
- How can I automatically reconnect to GridDB when this exception happens?
- Do I need to call
get_store()andget_container()again after a timeout? - Is this the correct approach?
try:
container.put(row)
except griddb.GSConnectionException:
# reconnect logic here?
Environment:
- GridDB Cloud (Free Tier)
- Python 3.x on Ubuntu 22.04
griddb-pythonclient