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

The ability for the client to reconnect itself #104

Open
searinminecraft opened this issue Apr 18, 2024 · 3 comments
Open

The ability for the client to reconnect itself #104

searinminecraft opened this issue Apr 18, 2024 · 3 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@searinminecraft
Copy link
Contributor

Summary

Client should reconnect itself when it disconnects from the websocket

What is the feature request for?

The core library

The Problem

I have a systemd user service that starts up my bot on system startup, as follows:

[Unit]
Description=linaSTK
After=multi-user.target
After=network-online.target
Wants=network-online.target

[Service]
WorkingDirectory=%h/Bots/lina
ExecStart=/usr/bin/python %h/Bots/lina/src/main.py
Type=idle
Restart=on-failure
RestartSec=15

[Install]
WantedBy=default.target

The problem is that if the websocket disconnects (which can happen randomly, sometimes after a few hours), it will treat it as if it exited successfully (because it exits with signal 0 if it disconnects) and will not restart the service. If I then the Restart property to always, it would then making shutting down the bot using commands not possible as the init system will restart it afterwards.

The Ideal Solution

There should be a logic in the client where if the websocket was to disconnect, it will attempt to re-establish a connection to the websocket, just like discord.py.

The Current Solution

No response

Additional Context

No response

@EnokiUN
Copy link
Owner

EnokiUN commented Apr 18, 2024

While I do plan to look into this in the future, it's probably going to have to wait until a proper rewrite. As a temporary solution however, you could try to wrap the bot starting code in a loop. If a disconnect also returns some specific error you can try to catch that in the loop and only restart then to reduce "scuff"

@searinminecraft
Copy link
Contributor Author

If a disconnect also returns some specific error

Well, it does not give an error if it disconnects, it just exits immediately as if nothing happened

@EnokiUN
Copy link
Owner

EnokiUN commented Apr 18, 2024

If a disconnect also returns some specific error

Well, it does not give an error if it disconnects, it just exits immediately as if nothing happened

You could just throw it into a loop for now.

@EnokiUN EnokiUN self-assigned this Apr 18, 2024
@EnokiUN EnokiUN added bug Something isn't working enhancement New feature or request labels Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants