Closed luongvm closed 10 years ago
It's a bug. It's been discussed a few times, but I don't think anyone has actually said why it occurs yet.
for now if the user handler goes into a situation like this i record the current items of both side and time into a log, and totally ignore the other person till i can verify this trade was done by visiting the bot history of trades myself. and then i update database manually. that's a bit hard work but i see no other ways round. in steam own version it will "ask" the server until have a confirmation whether the trade happened or failed.
I have never seen an actual issue in the exchange items as a result of it, so I have no idea why you are recording it as you have said above..
The only issue that stems from it is that the bot is left stuck as UserHandler.OnTradeClose()
does not get called.
I'll look into it further the next time it occurs on my bots.
it's because i have to reflect the trade result in my database. as the bot say failed but the trade succeeded, it will not update my database with correct information. like when user wish to take out an item from bot, but the item still exists when he/she visits his/her profile, because the function to update the database with info wasn't called ( 'cause trade wasn't succeeded - bot think so).
if you have a similar site or doing the same work, enlighten me with your method of doing it. maybe i'm simply doing it wrong, idk.
I'd just count it as a success.
but sometime the trade goes through, sometime it fails. i really can't tell the difference ;)
Really? For me (in the times I've encountered it) it's actually been successful 100% of the time even if it says otherwise.
Trade will only ever fail with the same exception if the bot's backpack is too full to accept the trade, the exception being thrown as a result of the response from Steam, two separate cases.
yes like imagooo said, no response received and a 'failed' response received are different cases. and i'm talking about when we got no response, seem like it was handled the same way as 'failed' response.
if (json == null || json.success != "true")
{
return false;
}
As @Jessecar96 said in #404, these exceptions need to be cleaned up. If the Bot gets no response from Steam, I don't think throwing a trade crashing exception is the best way to handle it, but instead perhaps retry a couple times and send some warnings to the log.
that's exactly i want. i said in my first message that the steam version of trading window will ask the server until it gets information about the final result of that trade. i really want to know how to do that, what about we send the webcmd again to fetch result? i wonder if it response as an invalid request because you can't accept twice ;)
ah another thing @iMagooo, i replace the throw in the web command with my own code to "handle" this. i blocked the current partner until i can intervene the trade to decide whether the trade actually done and if there is any inconsistency between trade history and my database.
@joturako In your case, you could probably just overload the '==' or '!=' operators for Inventories, check if the inventory before the trade is the same as the inventory after the trade. If not, then the trade completed successfully. Or have a function for the Inventory class that returns a list of Items that existed in the pre-trade inventory that are no longer in the inventory after trade.
Or a combination of both.
Both are workarounds for you until the exceptions are cleaned up.
@iMagooo clever ! i'm using a function like that to test my database after and before a trade...
I just had this happen to me, AcceptTradeWebCmd()
failed but the trade went through. The response from the server was
{"success":false,"results":{"success":11}}
A normal response, on the other hand, looks like this:
{"tradeid":"01234567890123456789","trade_status":1,"success":true}
I assume "11" is some sort of status code...
[Edit] It looks like even the official trade implementation doesn't use that results
code at all, it just re-queries when success == false
. That's what we should be doing.
This should be fixed in the latest version.
when i try to trade with a large number of items this command return false and thus making the logic jump to the wrong section. as i understand that this command send a post for which it may've reached the destination but the response from server may not come back, and giving bot the result that this command has failed. is this a bug or just that my coding problem? i have a function that update the item status in database, only if the trade is successful. But when this happen the database is not updated and i can't think of how to handle this problem.
i've notice that in the steam own version of trading the result displayed is always the actual result i.e. traded or error or ...