steampy icon indicating copy to clipboard operation
steampy copied to clipboard

Relogin problem...

Open ThreadShakur opened this issue 8 years ago • 23 comments

I have 24/7 bot with your greate lib. From time to time session die and iht's bot can't send/accept trades. If bot relogin in cycle, login failed. When i off program and run again login true, how to relogin without stopping program?

ThreadShakur avatar Feb 16 '17 13:02 ThreadShakur

I don't know, really.

bukson avatar Feb 16 '17 19:02 bukson

Question, I'm going to assume the answer is no, but if you combined this with another steam python library, like the steam lib, and log on through there, would you need to log in with steampy?

Zwork101 avatar Feb 17 '17 02:02 Zwork101

yes, bcs there is another class

ThreadShakur avatar Feb 17 '17 12:02 ThreadShakur

nobody don't know about this?

ThreadShakur avatar Feb 19 '17 08:02 ThreadShakur

I am not sure how many people use my lib, but i don't think it is a lot

bukson avatar Feb 19 '17 20:02 bukson

I meet this problem too, could anyone help me out?

iseekwonderful avatar Mar 14 '17 02:03 iseekwonderful

If you just recreate the SteamClient object is it fine? I mean, instead of stopping the program when the problems starts, try to reinitialize the client: client=SteamClient(...)

EmanueleSarte avatar Mar 15 '17 13:03 EmanueleSarte

Maybe browser send something like keep-alive request every k minutes and session is allive. Will be nice if somebody measure the time of logging out

bukson avatar Mar 15 '17 17:03 bukson

@Ermans I tried reinit client, but still failed, while looking into the response from steam server, when the second time login sent, the verify code (generated by shared key and timestamp) is wrong, the server's response is same as the situation while submit wrong code in browser. But I cant find out the where is wrong.

iseekwonderful avatar Mar 16 '17 16:03 iseekwonderful

@iseekwonderful Some time before the "session die", there are some activities (aka requests to steam server using your session) or there is a long time without requests? Just to be sure it isn't caused by inactivity

EmanueleSarte avatar Mar 16 '17 17:03 EmanueleSarte

I, personally, have never had that problem before, what are you running it on?

Zwork101 avatar Mar 16 '17 20:03 Zwork101

I have the same problem. I have simple script to accept all gifts and after some time of inactivity (no incoming offers) or when I log into this account from other pc (it's my main) session dies and script crashes. I've created small shell script to restart it every time it happens.

#!/bin/bash until python3 AcceptAllGifts.py; do echo "Script crashed. Respawning in 10 seconds..." >&2 sleep 10 done

It is decent workaround but still I would love to know why sometimes InvalidCredentials is raised even though login credentials are valid. As far as I understand this issue problem is caused by steam and their response to instant reloging but I'm just a neewbie in this matter ;)

WazzBtD avatar Jun 01 '17 00:06 WazzBtD

Problem is solved, it was due to initialization of default argument, once initialized in never changes default value, now it is ok

bukson avatar Jul 12 '17 07:07 bukson

sorry for reopening old issue but I'm facing same problem, refresh_session() gets new sessionid but i still get same error everywhere else, it just returns null, which requires relogin

Phalelashvili avatar Mar 04 '19 06:03 Phalelashvili

okay i found something weird, is_session_alive() returns false on every bot at same time, because they were logged in at same time but, i copied one of bots cookies over to browser, browser's session is still alive

Phalelashvili avatar Mar 04 '19 13:03 Phalelashvili

Yes, i'm interested in that case too. Maybe just do a process which every ~12 hrs do relogin? Or change 'remember_login': 'false' to true? That will keep a valid web session for weeks (that i found in that lib https://github.com/OmG3r/steam-trade) remember_login give a long-live session. And solution is: relogin every week, with 'remember_login': 'true'.

Kudisoldier avatar Mar 05 '19 17:03 Kudisoldier

Yes, i'm interested in that case too. Maybe just do a process which every ~12 hrs do relogin? Or change 'remember_login': 'false' to true? That will keep a valid web session for weeks (that i found in that lib https://github.com/OmG3r/steam-trade) remember_login give a long-live session. And solution is: relogin every week, with 'remember_login': 'true'.

i've changed remember login to true in my fork, and cookies stay alive, if i make requests.post request with same cookies it goes through, and if i inject cookies inside browser it also works, i have no clue what's causing session.post not to work (returns null), isn't cookies only thing session is saving?

Phalelashvili avatar Mar 05 '19 18:03 Phalelashvili

Yes, i'm interested in that case too. Maybe just do a process which every ~12 hrs do relogin? Or change 'remember_login': 'false' to true? That will keep a valid web session for weeks (that i found in that lib https://github.com/OmG3r/steam-trade) remember_login give a long-live session. And solution is: relogin every week, with 'remember_login': 'true'.

i've changed remember login to true in my fork, and cookies stay alive, if i make requests.post request with same cookies it goes through, and if i inject cookies inside browser it also works, i have no clue what's causing session.post not to work (returns null), isn't cookies only thing session is saving?

It's depending on what do u post requests. Maybe just u do wrong request? And because of this it's return null? try the following code: bot._session.post('https://steamcommunity.com/tradeoffer/'+tradeofferid+'/cancel', data={'sessionid': bot._get_session_id()}) and just change url and bot variable to yours.

Kudisoldier avatar Mar 05 '19 18:03 Kudisoldier

Guys if you fix something make a pull request I will gladly merge it.

bukson avatar Mar 07 '19 11:03 bukson

I can't reproduce my own issue on my local machine, I'm starting to think that i messed up on server (with proxy or something that causes request to return null), @astroaut can you describe your problem? it returns null?

Phalelashvili avatar Mar 09 '19 17:03 Phalelashvili

@Phalelashvili My issue is a short web-session on no relogin system. I have never get null from session, but i have got that response when i'm hit maximum requests to steam API.

Kudisoldier avatar Mar 09 '19 17:03 Kudisoldier

@Phalelashvili My issue is a short web-session on no relogin system. I have never get null from session, but i have got that response when i'm hit maximum requests to steam API.

looks like we're having two different issues, i get null on specific accounts even tho session is alive, i'm also using proxy so it's not api limit changing remember login to true fixes short session (i guess) steampy/login.py line 80, just change it to true

Phalelashvili avatar Mar 09 '19 17:03 Phalelashvili

small update: for some reason session is not sending steamRememberLogin cookie when making request which seems to be problem, but it's in cookieJar

client._session.get(url).request.headers

{'User-Agent': 'python-requests/2.19.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Cookie': 'browserid=12345; sessionid=superSecretSessionID; steamCountry=DE%7C0ec73fd8823a9da7c00a142962e1e413; steamLoginSecure=123ABC; steamMachineAuth00000000000000000=123ABC'}

requests.get(url, cookies=client.cookies.get_dict()).request.headers

{'User-Agent': 'python-requests/2.19.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Cookie': 'browserid=12345; sessionid=superSecretSessionID; steamCountry=DE%7C0ec73fd8823a9da7c00a142962e1e413; steamLoginSecure=123ABC; steamMachineAuth00000000000000000=123ABC; steamRememberLogin=00000000000000000ABCDE123'}

Phalelashvili avatar Mar 20 '19 18:03 Phalelashvili