Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue] $args returning null #2

Closed
GamerMedic opened this issue Jan 10, 2021 · 11 comments
Closed

[Issue] $args returning null #2

GamerMedic opened this issue Jan 10, 2021 · 11 comments
Assignees
Labels
Tech support a user needs help fixing things on their side.

Comments

@GamerMedic
Copy link

GamerMedic commented Jan 10, 2021

The $args param is always returning as null.

I get the [Websend] The server responded to the request with a 2xx code. Assuming request OK. (OK) message on my Minecraft server console, but the Empty argument! Don't just call ws/websend, add more arguments. string on the minecraft.php URL, and a Failed to connect error when trying to go PHP -> Spigot using the ExternalTimeSet.php test script.

Spigot seems to be reading the php page because any additional input I put on the page is included on the Minecraft console log, but my website is, seemingly, not receiving or sending data.

Any ideas?

EDIT: I'm using an additional port on my Minecraft server which is definitely open, and the php script is using the open port. Minecraft version: Paper 1.16.2. Websend version: 5.0.

@uncovery
Copy link
Owner

uncovery commented Jan 11, 2021

ok let's take one at a time and see where we get:

the message "Empty argument!" is because you need to run a command such as "/ws test test1 test2" from the minecraft server.
Those test.. are your arguments. Please try that. you can change the top of minecraft.php to

<?php 
global $CONFIG;

$CONFIG['checkpass'] = "PutYourPasswordHere";
$CONFIG['hashAlgorithm'] = "sha512";

$json = websend_connect();
// get the command arguments and return them to the console:
$arguments = $_POST['args'];
websend_command('PrintToConsole', 'you sent the arguments: '. implode(",", $arguments));

You can get the full file with this change here:
https://github.com/uncovery/Websend/blob/master/src/main/resources/minecraft.php

The above change however won't do anything unless you execute the command with arguments on the console of the minecraft server (or as a player).
and see if that does it. Once that works, we can check the rest.

Please try the latest version, this should make debugging this specific issue easier:

https://github.com/uncovery/Websend/releases/tag/5.1

@uncovery uncovery added the Tech support a user needs help fixing things on their side. label Jan 11, 2021
@uncovery uncovery self-assigned this Jan 11, 2021
@GamerMedic
Copy link
Author

I was always using arguments with the /ws command, but I tried it again anyway with the altered code you suggested.

Here are my logs:

PHP

[15-Jan-2021 00:17:15 Europe/London] Websend error: Invalid hash!
[15-Jan-2021 00:17:18 Europe/London] Websend error: Empty argument! Don't just call ws/websend, add more arguments.

Minecraft

[Server] INFO PlayerName issued server command: /ws test test1 test2
14.01 19:17:15 [Server] INFO [Websend] The server responded to the request with a 2xx code. Assuming request OK. (OK)
14.01 19:17:15 [Server] INFO [Websend] Command parsing: Execute JSON commnad {"action":"PrintToConsole","targetPlayer":null,"command":"Websend Error: Invalid hash!"}
14.01 19:17:15 [Server] INFO [Websend] Command parsing: printing text to console Websend Error: Invalid hash!
14.01 19:17:15 [Server] INFO [Websend] Websend Error: Invalid hash!

The password is the same in all Websend files, and the hash is sha512 in all of the files (hash was left as default, I only changed the password, which was copy and pasted to each file). It certainly shouldn't make a difference, but for clarity, I'm using an alphanumeric password with no special characters, and the password is greater than 16 chars in length.

N.B. Ignore the time discrepancy, I have a remote hosted Minecraft server which uses a different timezone to the one I'm in.

** Results after updating files from https://github.com/uncovery/Websend/releases/tag/5.1 **

No PHP error.

Minecraft

14.01 19:40:08 [Server] INFO [Websend] The server responded to the request with a 2xx code. Assuming request OK. (OK)
14.01 19:40:08 [Server] INFO [Websend] Command parsing: Execute JSON commnad {"action":"PrintToConsole","targetPlayer":null,"command":"you sent the arguments: test,test1,test2"}
14.01 19:40:08 [Server] INFO [Websend] Command parsing: printing text to console you sent the arguments: test,test1,test2
14.01 19:40:08 [Server] INFO [Websend] you sent the arguments: test,test1,test2

New error sending PHP -> Spigot

PHP

[15-Jan-2021 00:45:01 Europe/London] Websend connect() failed: Websend::__set_state(array(
   'timeout' => 3600,
   'hashAlgorithm' => 'sha512',
   'password' => ' **** ', // pass is the same in PHP and YAML files
   'host' => 're.da.ct.ed', // trusted.txt is using trust_all
   'port' => 8113, //opened port, ALTPORT is set to this port
   'stream' => false,
))

@uncovery
Copy link
Owner

ok so if the spigot->php does not show errors, is it working now? if not, can you post a "var_dump($_POST);" to a pastebin site?

regarding the php->spigot, I have to dive into the debug on the websend side there. Since I only took over the project from someone else, and it works for me, I never looked at that in detail. Will let you know if I find some code to improve.

@GamerMedic
Copy link
Author

Spigot->php is working now, after updating the files as you suggested. But php->spigot is throwing a Failed to connect message with this error:

[15-Jan-2021 00:45:01 Europe/London] Websend connect() failed: Websend::__set_state(array(
   'timeout' => 3600,
   'hashAlgorithm' => 'sha512',
   'password' => ' **** ', // pass is the same in PHP and YAML files
   'host' => 're.da.ct.ed', // trusted.txt is using trust_all
   'port' => 8113, //opened port, ALTPORT is set to this port
   'stream' => false,
))

(Obviously with the proper password and host)

@uncovery
Copy link
Owner

ok, great, then let me check if I can get more debug messages into it. btw I assume that
'password' => ' **** ' < you don't actually have spaces in there, right?

@GamerMedic
Copy link
Author

No, no spaces

@uncovery
Copy link
Owner

Ok, please try the new release 5.2 and

  • replace all the php files for testing with the new ones
  • copy-paste the minecraft console output relating to websend here
  • copy-paste the complete php output of the external timeset here as well.

@GamerMedic
Copy link
Author

GamerMedic commented Jan 15, 2021

Minecraft Output

issued server command: /ws test1
15.01 10:53:36 [Server] INFO [Websend] The server responded to the request with a 2xx code. Assuming request OK. (OK)
15.01 10:53:36 [Server] INFO [Websend] Command parsing: Execute JSON commnad {"action":"PrintToConsole","targetPlayer":null,"command":"you sent the arguments: test1"}
15.01 10:53:36 [Server] INFO [Websend] Command parsing: printing text to console you sent the arguments: test1
15.01 10:53:36 [Server] INFO [Websend] you sent the arguments: test1

PHP Output

ExternalTimeSet.php

Failed to connect.

Error Log

[15-Jan-2021 15:54:37 Europe/London] Websend connect() failed: Websend::__set_state(array(
   'timeout' => 3600,
   'hashAlgorithm' => 'sha512',
   'password' => 'PASSWORD',
   'host' => 're.da.ct.ed',
   'port' => 8113,
   'stream' => false,
))

var_dump($ws)

path_to_script/websend/ExternalTimeSet.php:12:
object(Websend)[1]
  public 'timeout' => int 3600
  public 'hashAlgorithm' => string 'sha512' (length=6)
  public 'password' => string 'PASSWORD' (length=19)
  public 'host' => string 're.da.ct.ed' (length=14)
  public 'port' => int 8113
  public 'stream' => boolean false

EDIT: added config.txt contents (if it helps)

#Configuration and settings file!
#Help: PASS: change the password to one of your choice (set the same in the server php file).
#Help: DEBUG_WEBSEND: shows debugging messages for easier tracking of bugs.
#Help: SALT: adds a salt to the hashed password when sending over bukkit -> php connection.
PASS=PASSWORD
#Optional settings. Remove the '#' to use.
URL=https://mydomain.com/websend/minecraft.php
WEBLISTENER_ACTIVE=true
ALTPORT=8113
DEBUG_WEBSEND=true
GZIP_REQUESTS=false

@uncovery
Copy link
Owner

uncovery commented Jan 16, 2021

can you please use the new .php files from the zip that has all the error reporting on and paste those errors here as well?
Also please the startup-messages from websend in the console log?

as of now I can only assume that your port is not actually open, maybe iptables or another firewall is blocking it?
Is the server on linux or windows?

thanks!

@GamerMedic
Copy link
Author

No other errors are showing. I've double checked that the port is definitely open, but I'll delve into it a bit more and if I get it working then I'll post the solution here.

My server is running Linux.

@uncovery
Copy link
Owner

check this one here to make sure the port is used by websend:
https://www.tecmint.com/find-out-which-process-listening-on-a-particular-port/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tech support a user needs help fixing things on their side.
Projects
None yet
Development

No branches or pull requests

2 participants