Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream expired due to inactivity. #50

Open
anubhuti24 opened this issue Mar 20, 2024 · 1 comment
Open

Stream expired due to inactivity. #50

anubhuti24 opened this issue Mar 20, 2024 · 1 comment

Comments

@anubhuti24
Copy link

  • Trying to establish a connection with TursoDB, connection has been established successfully but getting this error after giving a pause for some seconds before sending any request again.
  • It is basically closing the connection automatically.
@Meehai
Copy link

Meehai commented Sep 22, 2024

I had to make a workaround as this hasn't been fixed :

class ConnectionWrapper:
  def __init__(self, db_conn: libsql.Connection):
    self.db_conn = db_conn
    self.retry_connection_fn = None
  def execute(self, *args, **kwargs):
    try:
      return self.db_conn.execute(*args, **kwargs)
    except ValueError as e:
      if "expired" in str(e):
        self.retry_connection_fn()
        return self.db_conn.execute(*args, **kwargs)
      else:
        raise e

... (in main) ...
conn = ConnectionWrapper(libsql.Connection(url, token, ...))
conn.retry_connection_fn = lambda: libsql.Connection(url, token, ...))

basically holding a lambda that reconnects whenever needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants