steampy icon indicating copy to clipboard operation
steampy copied to clipboard

How to maintain a session throughout the day? / Как поддерживать сессию в течении дня ?

Open Requestedd opened this issue 4 years ago • 3 comments

I am running the following code / Я запускаю следующий код:

import json
import steampy
from steampy.client import SteamClient
from steampy.guard import generate_one_time_code, generate_confirmation_key, generate_device_id
from steampy.models import GameOptions
from steampy import market
from steampy.models import Currency

import time
from time import sleep


API_KEY = "~~~"
steamid = "~~~"
shared_secret_key = "~~~"
identity_secret_key = "~~~"
username = "~~~"
password = "~~~"

steamguard_data = {
    "steamid": steamid,
    "shared_secret": shared_secret_key,
    "identity_secret": identity_secret_key
}
steamguard_data = json.dumps(steamguard_data)

steam_client = SteamClient(API_KEY)
steam_client.login(username, password, steamguard_data)
for t in range(10):
	sess = steam_client.is_session_alive()
	if sess == None:
		print('None')
	else:
		wallet_balance = steam_client.get_wallet_balance()
		print('MY WALLET BALANCE: {}'.format(wallet_balance))
		sleep(600)

But after 600 seconds of waiting this error comes out / Но после 600 секунд ожидания выходит эта ошибка :

requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError(10060, 'Попытка установить соединение была безуспешной, т.к. от другого компьютера за требуемое время не получен нужный отклик, или было разорвано уже установленное соединение из-за неверного отклика уже подключенного компьютера', None, 10060, None))

It looks like there were some problems with establishing a connection, as I suppose, it's all about the lost session. Does Steam.py have a function to revive the session if it is over? Or how can you even make a bot work for a long period of time, but with long pauses? / Похоже возникли проблемы с установкой соединения , как я предполагаю , всё дело в потерявшейся сессии. Есть ли в steam.py функция возрождения сессии в случае , если она закончилась ? Или как вообще можно заставить работать бота в течении долгого промежутка времени , но в большими паузами ?

Requestedd avatar Feb 07 '21 14:02 Requestedd

I was given a hint that today a good option is to use a session check (is_session_alive()) every few minutes, this is certainly not very convenient in the standard sense, but on the other hand, it should support a long session. I think there are no other options yet?

/ Мне дали подсказку , что на сегодня неплохим вариантом является использование проверки сессии ( is_session_alive() ) каждые несколько минут , это конечно не совсем удобно в стандартном понимании , но с другой стороны должно поддерживать длительную сессию. Я думаю на пока что других вариантов нет ?

Requestedd avatar Feb 11 '21 09:02 Requestedd

I have the same issue, my session expires during a process.

hashdashme avatar Feb 28 '21 14:02 hashdashme

I've tried to replicate but its not happening to me. I've done 45 minutes test with 15 minutes wait time in between, and there's no problem, session is still alive.

The only difference from your code is I pass the name of file with steamguard json to steamguard_data argument instead of serialized json string.

PS: its also worth noting that Steam has maintenance window day on Tuesday/Wednesday, so it means interruptions with sessions are nearly guaranteed in outage times. See if this issue happens on any other day.

dimon222 avatar Mar 03 '21 03:03 dimon222