BuStudios / StashConnect

An API wrapper for stashcat.
MIT License
4 stars 1 forks source link

Websocket connection closes automatically after some time #4

Open BuStudios opened 1 month ago

BuStudios commented 1 month ago

The websocket connection to stashcat closes after some time automatically and the code exits, without any logged errors int the console. Might be a problem that is not from StashConnect but rather from SocketIO as it worked fine before. Happens mostly on Linux arm64 according to my testing.

import stashconnect

client = stashconnect.Client(
    email="[my email]",
    password="[my password]",
)

@client.event("notification")
def message_received(data: stashconnect.Message):
    print(f"Message received: {data.content_encrypted}")
    if (data.type_id == [chat_id]):
        data.respond(f"[automated] message received - bot active \n`{data.content_encrypted}`", encrypted=False)

@client.loop(seconds=60)
def loop():
    client.messages.send("[chat_id]", "[automated] looped message - bot active", encrypted=False)

client.run(debug=True)
BuStudios commented 1 month ago

Update: Seems like the issue only occurs on Linux since i have just run the code above on a Windows machine for about 30 minutes and it has not yet exited and the websocket connection still is connected. I'll do some more tests on Linux and on Windows too.

JSmaler commented 1 month ago

Yea, that may be it, since I am on Linux. (Fedora 40 specifically, if that helps in any way.)

I'll try on a Windows WM as well, just to confirm the issue to be OS-specific.