libsql icon indicating copy to clipboard operation
libsql copied to clipboard

I keep getting `HRANA_WEBSOCKET_ERROR: WebSocket was closed`

Open Tomperez98 opened this issue 1 year ago • 8 comments

From time to time my server is unable to connect to turso database due to this error: sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) HRANA_WEBSOCKET_ERROR: WebSocket was closed

This is the sqlalchemy engine configuration

self.db_engine = create_engine(
                url=f"sqlite+{db_url}/?authToken={db_auth_token}",
                echo=False,
                connect_args={"timeout": 60},
            )

dependencies

libsql-client==0.3.0
    # via sqlalchemy-libsql
sqlalchemy==2.0.28
    # via sqlalchemy-libsql
sqlalchemy-libsql==0.1.0

Tomperez98 avatar Mar 13 '24 00:03 Tomperez98

Same here, we did setup everything according to Turso docs, but the app stops working after some time (not sure after what period of time tho). Restart fixes the issue.

jsardev avatar Apr 06 '24 11:04 jsardev

Same with me

tmlnv avatar Jul 11 '24 10:07 tmlnv

same

CarlosBueno99 avatar Jul 11 '24 14:07 CarlosBueno99

Also have the same issue

Thandden avatar Jul 16 '24 15:07 Thandden

same issue

badbye avatar Jul 25 '24 07:07 badbye

Same issue here, this was not happening before :( Is the issue that the websocket needs to be "kept-alive"? Not sure what the best practices are for starting a keep-alive thread in sqlalchemy

devtanna avatar Jul 29 '24 08:07 devtanna

Adding the following param pool_pre_ping fixed it for me 🙂

create_engine(
  url=f"...",
  pool_pre_ping=True
)

devtanna avatar Jul 29 '24 13:07 devtanna