Philipp15b / go-steam

Steam's protocol in Go to allow automation of different actions on the Steam network without running an actual Steam client. Includes APIs for friends, chatting, trading, trade offers and TF2 crafting.
https://pkg.go.dev/github.com/Philipp15b/go-steam/v3
Other
392 stars 131 forks source link

Error connecting. #93

Closed Hexer10 closed 5 years ago

Hexer10 commented 6 years ago

When I call

    myLoginInfo := new(steam.LogOnDetails)
    myLoginInfo.Username = "user"
    myLoginInfo.Password = "pass"

    client := steam.NewClient()
    client.Connect()

Sometimes it works but then I get this error:

 Error reading from the connection: EOF

or sometimes is throws an error on client.Connect():

Connect failed: dial tcp 162.254.196.43:27020: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

How can I solve this?

Hexer10 commented 6 years ago

I tought I've solved this but I'm getting again the errors

Nuc1eoN commented 5 years ago

Hey I am also getting an error like this. How can we fix this?

Connecting to random server.
Error: Connect failed: dial tcp 208.78.164.11:27019: connect: connection timed out

EDIT: I guess the IP list is out of date and this has not been ported to the go codebase https://github.com/SteamRE/SteamKit/pull/293 ?

EDIT2: Turns out the issue is indeed, that pretty much the whole IP list in servers.go is outdated. Normally after the first connection a serverlist.json with up-to-date IPs is being generated and used thereafter, but that does not help on the initial login.

So what I did was copy the IPs from https://api.steampowered.com/ISteamDirectory/GetCMList/v1/?cellid=0 into servers.go and delete the old ones.

Then when the iniital login succeeds, you also get a fresh serverlist.json each time.

Philipp15b commented 5 years ago

Yeah, the IP list needs to be updated periodically. I am happy to accept pull requests for this.

Hexer10 commented 5 years ago

I don't know if it would cause any issues, but could we just request a new list of IPs every time we try connecting to the steam servers?

Nuc1eoN commented 5 years ago

Yeah not sure either, I mean the server list is publicly accessable over the api I linked above.

Philipp15b commented 5 years ago

Actually, I think we already have an implementation for fetching the server list: InitializeSteamDirectory. So a call to this function for the first Connect() is also possible.

A simple change around here to something like

if !steamDirectoryCache.IsInitialized() {
    InitializeSteamDirectory()
}
if steamDirectoryCache.IsInitialized() {
    server = steamDirectoryCache.GetRandomCM()
} else {
    server = GetRandomCM()
}

should fix the problem.

Philipp15b commented 5 years ago

I've both updated the IP list and added automatic Steam Directory fetching, which should solve the problem. Thanks for the reports!