surrealdb / surrealdb.py

SurrealDB SDK for Python
https://surrealdb.com
Apache License 2.0
181 stars 53 forks source link

Bug: Parameter Max Size in Websocket does not work #111

Open Dash83UPV opened 6 days ago

Dash83UPV commented 6 days ago

Describe the bug

Although we can set the max_size value when we create the Surreal() WebSocket connection, this is not propagated to the actual websocket connection. Therefore, when we request data bigger than 1MByte the WS crashes.

Steps to reproduce

ISSUE

Create the table my_table with more than 1MByte of data. Try to get all the records.

DB = Surreal("ws://192.168.0.1:8000/rpc", max_size=2**30)

async def main2():
    await DB.connect()
    await DB.signin({"user": "root", "pass": "root"})
    await DB.use(database="test", namespace="test")

    try:
        data = await DB.select("my_table")
        print(len(data))
    except Exception as e:
        data = str(e)
        print(data)

It will crush due to error sent 1009 (message too big); no close frame received Payload to Big XXX > 1MByte

SOLUTION

Possible solution, but perhaps there is more work to do.

In file ws.py change the line

self.ws = await websockets.connect(self.url)  # type: ignore

to

self.ws = await websockets.connect(self.url, max_size=self.max_size)  # type: ignore

Expected behaviour

The expected behavior is for the WS client connection to be opened using the max_size parameter that was given during the Surreal object construction.

SurrealDB version

surreal 1.4.0 for debian on aarch64

surrealdb.py version

surrealdb.py 0.3.2 for windows on aarch64 using Python 3.9.1

Contact Details

alclial@upvnet.upv.es

Is there an existing issue for this?

Code of Conduct

4F2E4A2E commented 6 days ago

I am experiencing the same issue. We have a few components in python which must talk to the db. Python SDK is crucial for us to continue with surrealdb.