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

Can't catch Client creation error #15

Closed
Picatek opened this issue Apr 24, 2015 · 9 comments
Closed

Can't catch Client creation error #15

Picatek opened this issue Apr 24, 2015 · 9 comments

Comments

@Picatek
Copy link

Picatek commented Apr 24, 2015

Gets syntax error when used wrong/none existing ip address when creating client object with wrong ip address:
In the following example, if there is no router with the address: 10.20.30.42 then I get the following errors:

Parse error: syntax error, unexpected end of file in /www/cgi-bin/src/PEAR2/Net/Transmitter/Exception.php on line 37

Fatal error: Call to a member function getTransmitter() on a non-object in /www/cgi-bin/src/PEAR2/Net/RouterOS/Client.php on line 747

Exeample:
try{
$client = new RouterOS\Client('10.20.30.42', 'user','PASS');
} catch(Exception $ex){

 echo 'Error...';

}

@boenrobot
Copy link
Member

Do you get any other errors when the IP does exist? What is your PHP version?

The parse error leads me to believe the problem is you're using PHP 5.2, but then again, your own file should've triggered its own parse error in that case.

@Picatek
Copy link
Author

Picatek commented Apr 24, 2015

No. No other error. Everything works fine if the IP exist.
X-Powered-By: PHP/5.4.5

@boenrobot
Copy link
Member

I tried with 5.4.6 and 5.4.0 and couldn't duplicate this issue. Also tried specifically with 5.4.5, all tried after extracting the tgz archive, and including its Autoload.php with no other code... I'm always getting "Error...", exactly as expected.

Have you made any modifications to /www/cgi-bin/src/PEAR2/Net/Transmitter/Exception.php at all? Could you possibly try with any other PHP version and/or the same setup (including the exact same files) but on Windows?

@Picatek
Copy link
Author

Picatek commented Apr 25, 2015

  1. Thanks for your time I really appreciate it.
  2. I haven't made ANY changes to any of the package files.
  3. FYI I am running it on an Openwrt Metarouter and the PHP package is from :
    http://openwrt.wk.cz/attitude_adjustment/mr-mips/packages/
    I will try next week to install another PHP version (4.4.9-1 ?) but not sure when I will have the time

@boenrobot
Copy link
Member

Ah. That's interesting...

How much memory does the MetaRouter have allocated for it? Try giving it some more. I'm thinking maybe by the time PHP decides to parse Exception.php, the router goes out of memory in the middle of parsing, ultimately causing the parse error.

I'm going to try setting up Openwrt too... (I've been meaning to try to anyway, and now I have a good motivation to)

@boenrobot
Copy link
Member

Hmm... I'm trying to run those exact images on a MetaRouter with 64MiB RAM, and I get a segmentation fault. I get that even from just a phpinfo()... Although I'm using php-cli, which may be part of my problem.

(I always knew MetaRouter is not exactly a stable environment, but this is ridiculous...)

@boenrobot
Copy link
Member

After some more digging, I'm able to almost reproduce the error. The error you're experiencing is likely related. The segfault from before seems to be a known issue that's already fixed in trunk, so that's what I did. I used the 31411 image from http://openwrt.wk.cz/trunk/mr-mips/, with all related modules from there.

With that PHP version (5.3.10), I get no segfaults on phpinfo(), and trying to run your code gives me

Parse error: syntax error, unexpected $end in /usr/share/htdocs/PEAR2_Net_RouterOS
-1.0.0b5/src/PEAR2/Autoload.php on line 243

Further trial&error showed the error is... very silly... There needs to be one blank line at the end of all files, or this particular PHP borks. This is already the case for all files on the "develop" branches of Net_RouterOS and Net_Transmitter.

The only thing that's not yet fixed is PEAR2/Autoload.php, which you can manually modify: Just add a new line at the end.

The exact error you're experiencing might be something different, as you would've seen the Autoload.php error yourself as well... Unless maybe you used composer for the installation? In that case, you don't need to deal with PEAR2/Autoload.php anyway.

@Picatek
Copy link
Author

Picatek commented Apr 27, 2015

This solved the problem(added a few empty lines to Autoload.php)
Thanks

@boenrobot
Copy link
Member

The latest version now includes a fixed version of PEAR2_Autoload.

I haven't tried to run it on a MetaRouter again (just because of how ridiculously difficult it still is to set up...), so please let me know if it still happens with it. I'll close this issue now anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants