Philipp15b/go-steam

Error connecting.

Closed this issue · 7 comments

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?

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

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 SteamRE/SteamKit#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.

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

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?

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

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.

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