Open waylaidwanderer opened 11 years ago
Here's what I did for my bots. Might not be the best, but it works. I modified my bots to only get one schema in Program.cs and share it so this probably won't work on the real SteamBot, but you get the concept of it.
if (MasterSchema == null)
{
MasterSchema = null;
Console.WriteLine("Downloading schema...");
while (MasterSchema == null)
{
try
{
MasterSchema = Schema.FetchSchema(configObject.ApiKey);
}
catch (Exception)
{
MasterSchema = null;
Console.WriteLine("Problem while getting the schema. Retrying in 10 seconds...");
Thread.Sleep(10000);
}
}
Console.WriteLine("Downloaded schema!");
}
It will work, you just have to change the variable names because I changed some for the ScrapTF version.
Jesse you need some mutexes or locks up in this bitch
The current SteamBot does have a mutex for downloading the schema. Adding in a retry as @Jessecar96 suggested sounds good though.
Last I checked you guys were trying some file lock shit
@geel9 It's a mutex. The lock file mess didn't work IIRC.
I haven't run into this error for a while now.
I thought it was resolved. Perhaps it needs to be more robust in general?
I changed the behaviour of the schema fetching to use the modified since header and if there's any issues with the API it loads the local schema if present.
https://github.com/StormReaper/SteamBot/commit/4c6dd1f8144e66ac3bb3e7a479fe10743b797cb8
This issue is mainly present with CSGO. Those api's are offline every other day. @Jessecar96 that fixed it, thanks.
You could make it so that the Schema retrieves the last cache whenever it encounters a WebException, by changing Schema.FetchSchema()
and Schema.GetSchemaString()
. That way, it will only crash if there is no schema file cached when the schema server is down.
Pastebin link to those two methods
I can't submit a PR as my fork of this repository is just for personal use (and tweaks). Could somebody test the changes above to see if they work on their own?
Here's what happens:
Is there any way to avoid this? Perhaps by throwing a try-catch around it? That would probably work as an interim method, but perhaps there's a more elegant solution.