SteamRE / SteamKit

SteamKit2 is a .NET library designed to interoperate with Valve's Steam network. It aims to provide a simple, yet extensible, interface to perform various actions on the network.
GNU Lesser General Public License v2.1
2.58k stars 493 forks source link

Trying to find the answer this Connection Issue #394

Closed STRATZ-Ken closed 7 years ago

STRATZ-Ken commented 7 years ago

First off, let me say my code works fine under the build from around August of last year (2016). I am really not sure what has been added or changed, but every time I attempt to upgrade to the latest version, I have this issue. I would really love to solve it.

So, I run a lot of bots on one machine. From everything I checked, nothing is sent to steam thats hardcoded that would block me (For example Local Ip address or hardware Ids, or Mac Ids). When I make my 1st connection attempt, I get a positive result.

2017-05-17 13:33:03.0247 .Connect Debug: Connecting to Steam at 162.254.195.46:27018  AsyncTaskMethodBuilder`1.Start => <RequestMatch>d__42.MoveNext => .Connect
2017-05-17 13:33:03.0247 .Connect Debug: SteamKit2.Discovery.NullServerListProvider  AsyncTaskMethodBuilder`1.Start => <RequestMatch>d__42.MoveNext => .Connect
2017-05-17 13:33:03.8793 .OnConnected Debug: OnConnected result OK  <>c__DisplayClass10_0.<Handle>b__1 => Callback`1.Run => .OnConnected
2017-05-17 13:33:04.0534 +<Connect>d__35.MoveNext Debug: Connected to Steam  ExecutionContext.RunInternal => MoveNextRunner.InvokeMoveNext => <Connect>d__35.MoveNext

As I continue, I then try to login, but I dont get ANYTHING on the void OnLoggedOn(SteamUser.LoggedOnCallback callback)

So then I run my Disconnect Method.

2017-05-17 13:33:34.1826 .Disconnect Debug: Disconnect  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:33:34.1826 .Disconnect Debug: IsConnected: False  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:33:34.1826 .Disconnect Debug: SessionId:   MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:33:34.1826 .Disconnect Debug: SessionToken: 0  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:33:34.1826 .Disconnect Debug: SteamId:   MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:33:34.1826 .Disconnect Debug: LocalIP: 255.255.255.255  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:33:34.1826 .Disconnect Debug: CellId:   MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect

This is before the SteamClient.Disconnect.

2017-05-17 13:33:34.1826 .Disconnect Debug: IsConnected: False  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:33:34.1826 .Disconnect Debug: SessionId:   MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:33:34.1826 .Disconnect Debug: SessionToken: 0  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:33:34.1826 .Disconnect Debug: SteamId:   MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:33:34.1826 .Disconnect Debug: LocalIP: 255.255.255.255  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:33:34.1826 .Disconnect Debug: CellId:   MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:33:34.1906 .Disconnect Debug: ConnectedUniverse: Invalid  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect

This is after I call SteamClient.Disconnect. Not much different.

Now, my bot retries again. This time, I cannot even connect to Steam.

2017-05-17 13:33:36.1541 .Connect Debug: Connecting to Steam at 162.254.195.44:27019  AsyncTaskMethodBuilder`1.Start => <RequestMatch>d__42.MoveNext => .Connect
2017-05-17 13:33:36.1541 .Connect Debug: SteamKit2.Discovery.NullServerListProvider  AsyncTaskMethodBuilder`1.Start => <RequestMatch>d__42.MoveNext => .Connect
2017-05-17 13:34:06.7226 +<Connect>d__35.MoveNext Debug: Unable to connect to Steam  ExecutionContext.RunInternal => MoveNextRunner.InvokeMoveNext => <Connect>d__35.MoveNext
2017-05-17 13:34:06.7236 .Disconnect Debug: Disconnect  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:06.7236 .Disconnect Debug: IsConnected: True  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:06.7236 .Disconnect Debug: SessionId:   MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:06.7236 .Disconnect Debug: SessionToken: 0  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:06.7236 .Disconnect Debug: SteamId:   MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:06.7236 .Disconnect Debug: LocalIP: 10.0.0.102  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:06.7236 .Disconnect Debug: CellId:   MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:06.7236 .Disconnect Debug: ConnectedUniverse: Public  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:07.8865 .Disconnect Debug: IsConnected: False  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:07.8865 .Disconnect Debug: SessionId:   MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:07.8865 .Disconnect Debug: SessionToken: 0  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:07.8865 .Disconnect Debug: SteamId:   MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:07.8865 .Disconnect Debug: LocalIP: 255.255.255.255  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:07.8865 .Disconnect Debug: CellId:   MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect
2017-05-17 13:34:07.8865 .Disconnect Debug: ConnectedUniverse: Invalid  MoveNextRunner.InvokeMoveNext => <RequestMatch>d__42.MoveNext => .Disconnect

Above is the Connect, Debug print out, then the Disconnect is called, then the out printout.

The odd part is you can see "IsConnect" is actually true, but I never got any data on void OnConnected(SteamClient.ConnectedCallback callback)

Really not sure where to go from here. I am using a lot on one machine, but even if I am getting rate limited, shouldn't SteamKit still give me some type of response?

I can answer any questions.

It has to be related to having multiple connections per machine, but I can't see where, and occasionally it just works but eventually stops again.

STRATZ-Ken commented 7 years ago

Spoke with AzuiSleet_ a lot in IRC.

It is true that HardwareUtils plays a role. After altering that (String.Random()), I was able to connect without an issue. I think we should update the Comments in that field as I think the rules have maybe changed again?

One thing AzuiSleet_ thought was weird is that sometimes, when the rate limit occurs I can Disconnect then reconnect and get 1 more request. If I disconnect and Reconnect again, I get 1 request, then the GC times out. He said it may be a bug. Any insight? Specifically the DotaMatch GC call.

JustArchi commented 7 years ago

As I continue, I then try to login, but I dont get ANYTHING on the void OnLoggedOn(SteamUser.LoggedOnCallback callback)

I'm 99% sure your issue is https://github.com/SteamRE/SteamKit/issues/305.

JustArchi commented 7 years ago

And if you want a solution that doesn't require modifying SK2 code then take a look at https://github.com/JustArchi/ArchiSteamFarm/blob/master/ArchiSteamFarm/Bot.cs#L1383-L1388 and https://github.com/JustArchi/ArchiSteamFarm/blob/master/ArchiSteamFarm/ArchiHandler.cs#L97-L149

STRATZ-Ken commented 7 years ago

@JustArchi I removed that all together in a fork and I just do a Random String of 10 Characters each time. Seemed to help with Part A of my issue. Part B is still unknown.

Netshroud commented 7 years ago

Does it all work fine if you use v1.8.3 from NuGet, or does the issue persist?

STRATZ-Ken commented 7 years ago

I believe I was using maybe a bit before 1.8.3.

So after many hours, I believe it is in-fact the Hardware Utils. If you run 50 instance of steamkit you wont even be able to connect. If you alter the HardwareId on each, connection is possible. Since SteamKit has a static hardware id on load, over time eventually your hardware id gets banned and you have kill SteamKit to start over.

@JustArchi I used your method, but when running a lot of bots, running no HardwareId is the same as running the same one, eventually I was limited. I tried creating a new HardwareId on each Login, but still something in SteamKit must of stayed the same and eventually I was blocked.

Not sure how the 1st connection is different from the 2nd connection but there has to be something. Referencing my 1st post as an example, the Ip address is correct in the 2nd connection but wrong in the 1st.

Netshroud commented 7 years ago

Was this ever resolved? I seem to recall some further discussion in IRC but it hasn't been documented here.

yaakov-h commented 7 years ago

Closing due to inactivity.