8

Using 1and1 linux shared hosting,

I have installed:

PHP Version 7.0.27 PHP PhantomJS 2.1.1

PHP PhantomJS all values are null

Whenever I make a request with:

$client = Client::getInstance();

$client->getEngine()->setPath($main_path.'core/composer/bin/phantomjs');
$client->getEngine()->addOption('--ssl-protocol=any');
$client->getEngine()->addOption('--ignore-ssl-errors=true');
$client->getEngine()->addOption('--web-security=false');
$client->getEngine()->addOption('--debug=true');
$client->getEngine()->addOption('--local-to-remote-url-access=true');

$request = $client->getMessageFactory()->createRequest("http://luclaverdure.com");
$response = $client->getMessageFactory()->createResponse();

$client->send($request, $response);
var_dump($request);
var_dump($response);

if($response->getStatus() === 200) {
    $resp = $response->getContent();
    var_dump($resp);
}

I have a bunch of null values and the URL doesn't get processed by phantomJS...

Request:

object(JonnyW\PhantomJs\Http\Request)#113 (12) {
    ["type":protected]=> NULL
    ["headers":protected]=> array(0) {}
    ["settings":protected]=>
      array(1) {
        ["resourceTimeout"]=>
        int(5000)
      }
    ["cookies":protected]=>
      array(2) {
        ["add"]=>
        array(0) {
        }
        ["delete"]=>
        array(0) {
        }
      }
    ["data":protected]=>
      array(0) {
      }
    ["url":protected]=>
      string(59) "http://luclaverdure.com"
    ["method":protected]=>
      string(3) "GET"
    ["timeout":protected]=>
      NULL
    ["delay":protected]=>
      int(0)
    ["viewportWidth":protected]=>
      int(0)
    ["viewportHeight":protected]=>
      int(0)
    ["bodyStyles":protected]=>
      array(0) {
      }
}

Response:

object(JonnyW\PhantomJs\Http\Response)#263 (9) {
    ["headers"]=>
      NULL
    ["status"]=>
      NULL
    ["content"]=>
      NULL
    ["contentType"]=>
      NULL
    ["url"]=>
      NULL
    ["redirectURL"]=>
      NULL
    ["time"]=>
      NULL
    ["console"]=>
      NULL
    ["cookies"]=>
      NULL
}

It just never returns content

Please help

Edit: Logs:

string(1413) "2018-02-25T22:31:25 [DEBUG] CookieJar - Created and will store cookies in: "cookies.txt" 1 0x1b67967 /kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs() [0x1b67967] 2 0x1baaaf5 /kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs() [0x1baaaf5] 3 0x198c463 /kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs() [0x198c463] 4 0x1ab3982 /kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs() [0x1ab3982] 5 0x79abb9 /kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs() [0x79abb9] 6 0x76b6f9 /kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs() [0x76b6f9] 7 0x750a5d /kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs() [0x750a5d] 8 0x41cd89 /kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs() [0x41cd89] 9 0x41f5c4 /kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs() [0x41f5c4] 10 0x415b86 /kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs() [0x415b86] 11 0x2b1fc0917b45 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x2b1fc0917b45] 12 0x4176a1 /kunden/homepages/0/d220355082/htdocs/bitme/core/composer/bin/phantomjs() [0x4176a1] PhantomJS has crashed. Please read the bug reporting guide at http://phantomjs.org/bug-reporting.html and file a bug report. Segmentation fault " int(0) NULL

Edit:

If I replace the phantomJS with latest download,

I get libicui18n.so.55 missing dependency

how can I install this with Composer?

Please note that this needs to be installed on a shared hosting machine, hence I do not have root/sudo access on the machine

All help is appreciated.

Kasia Gogolek
  • 3,374
  • 4
  • 33
  • 50
Luc Laverdure
  • 1,398
  • 2
  • 19
  • 36
  • The url you are requesting does not return a 200 but a 302. You can check this using chrome inspector and the network tab. Everything works fine if you test the 302 status. – user1453870 Feb 26 '18 at 02:35
  • Actually it returns int(0) – Luc Laverdure Feb 26 '18 at 02:40
  • `$request = $client->getMessageFactory()->createRequest('http://luclaverdure.com', 'GET'); $response = $client->getMessageFactory()->createResponse(); $client->send($request, $response); var_dump($request->getStatus()); // 302 if($response->getStatus() === 302) { var_dump($response->getContent()); die; }` Returns your homepage html's. Are you sure you don't have a host setting setup to a different IP or something like that? – user1453870 Feb 26 '18 at 02:43
  • if you look at the response code above: ["status"]=> NULL – Luc Laverdure Feb 26 '18 at 02:47
  • Tried another other urls, I still get 0 as status – Luc Laverdure Feb 26 '18 at 03:00
  • Updated entry, please have a look @user1453870 – Luc Laverdure Feb 26 '18 at 18:49
  • Things are getting a little bit complicated if this is a shared hosting as you could find yourself pitted against permissions errors and such, you could try something like that: https://stackoverflow.com/questions/35840359/libicuuc-so-55-cannot-open-shared-object-file Which is to download the binary and manually install it, though on a shared hosting it may not work. Unfortunately, if this doesn't work I think you'll have to contact the hosting company and exchange with them on the issue because your code is fine. – user1453870 Feb 26 '18 at 20:30

1 Answers1

2

Check if your system runs SELinux (you can check that with sestatus) —- it can (and it will) try to harm PhantomJS, and it looks just like that.

Check out "SELinux" section on phantomjs.org/troubleshooting for official solution.

Tejus
  • 694
  • 1
  • 7
  • 19