race condition in remoteclient01a.py
The script assumes that after sending a command, the next line that appears on the console is the result of that command, which works most of the time, but sometimes returns a random line from the console, often grief alerts.
Either this script has to validate the result (does it actually have enough information to do that?) and read lines until it finds the expected answer, or all scripts that use this have to check the results of their calls to remoteclient and retry on error.
Comments (7)
-
-
For commands implemented in or added to
ServerConsoleCommands
, you can use something like this:String[] args = input.split(" "); MessageReciever receiver = new MessageReciever() { @Override public String getName() { return "Pipe"; } @Override public void notify(String message) { // Do your handling here } }; ServerConsoleCommands.parseConsoleCommand(receiver, args[0], args);
This won't work for console commands implemented via the
SERVER_COMMAND
hook though, which will probably still be a majority (if not all). -
It is not up to remoteclient to validate the input; this is an interface component, and must not introduce any performance penalties of any kind by doing things like error checking. Error checking is up to the calling application; many of the scripts which are error-sensitive perform checks on remoteclient output, and rerun the query if it is not of the expected sort.
The fundamental problem isn't with remoteclient, which does exactly what it's intended to, but with general lag in the server which means commands are not answered immediately. That's a more overarching issue though.
One solution we've discussed is the possibility of having exec listen on its own port as a tcp socket, thus taking it out of the shared stream of data with the multiplexer.
Either way, i emphasise this script must not be bloated with any additional checking code, not that it could be effective without context - leave that to the calling application which knows what output it's expecting.
However, if there are any scripts or programs that are missing error checking and should have it, please do add it. The (no longer used) script listplayers.sh has a good example of a wait-and-retry loop with a limited number of retries: https://bitbucket.org/minecraftonline/scripts/src/ee6cc9015bf597c034c5fae73d44a3e096fc526f/listplayers.sh?at=master
-
- marked as enhancement
-
Is there a fixed set of commands whose output has to get checked? It's probably not all that hard to convert those to BaseCommands so we can use a separate socket to emit the results on.
-
Just the exec stuff: http://minecraftonline.com/wiki/Exec#ServerCommands
-
- changed status to resolved
Update /tpto to use new file and format. Fixes
#2→ <<cset ab8db2aeb075>>
- Log in to comment
Is there a mechanism in Canary to get a channel/pipe for a single command/plugin?