php-phantomjs
php-phantomjs copied to clipboard
Error on open debug
when i open debug like this.
$client->getEngine()->debug(true);
There is no response in the client in a long time.
I guest it that there is some problem in the debug option.
in addition,I use the v4.0 php-phantomjs.
if there anyone can hep me ?
Have the same problem; looks like PhantomJs just hangs. Running:
ps aux | grep phantom
and copying the command line executed for that process shows that phantomjs works correctly. For me it appears that the issue is that the problem is with line 112 of Procedure.php:
$result = stream_get_contents($pipes[1]);
for some reason the library just hangs waiting.
@JalfResi Is this the same issue as https://github.com/jonnnnyw/php-phantomjs/issues/74?
Same issue for me, i 've installed the 4.5.1 version
I have a feeling that the amount of debug information PhantomJS outputs is causing a bottleneck in the response. I would imagine the response object gets very big by the time it's being parsed back into PHP.
I will look into reducing the amount of debug information and just output what is useful to developers. Is there anything in particular that you are expecting in the debug output so I can get an understanding of what to include?
@AdriwanKenoby do you have URL that produces this issue so I can run some tests?
Can be reproduced with by turning on debug and calling http://www.buzzfeed.com/johnc4197e36ba/lonely-bridget-still-lonely-16imt
I work on a project that aim to monitoring websites. It is integrated in OroCRM so i can't give you the entire project, it is to big. I can try to make a minimal symfony project if ask for it. Or u can integrate this code : `<?php
namespace Sinabs\MonitoringBundle\Services;
use JonnyW\PhantomJs\Client; //use JonnyW\PhantomJs\DependencyInjection\ServiceContainer; //use Sinabs\MonitoringBundle\Model\CustomResponse;
class Phantom {
protected $client;
protected $request;
protected $response;
public function __construct() {
//$location = __DIR__ . '/../Resources/public/js/phantom/';
//$serviceContainer = ServiceContainer::getInstance();
//$procedureLoader = $serviceContainer->get('procedure_loader_factory')
// ->createProcedureLoader($location);
$this->client = Client::getInstance();
$this->client->getProcedureCompiler()->disableCache();
//$this->client->getProcedureLoader()->addLoader($procedureLoader);
//$this->client->setProcedure('monitoring');
$this->client->getEngine()->debug(true);
}
public function load($url) {
/**
* @see JonnyW\PhantomJs\Http\Request
* */
$this->request = $this->client->getMessageFactory()->createRequest($url, 'GET');
/**
* @see JonnyW\PhantomJs\Http\Response
* */
//$this->response = new CustomResponse();
$this->request = $this->client->getMessageFactory()->createResponse();
// Send the request
$this->client->send($this->request, $this->response);
}
public function isHttpCodeValid() {
$http_code = $this->response->getStatus();
return ($http_code != 200 && $http_code != 304) ? false : true;
}
public function getHttpCode() {
return $this->response->getStatus();
}
public function getContent() {
return $this->response->getContent();
}
public function getTime() {
return $this->response->getTime();
}
public function getResponseTime() {
return $this->response->getResponseTime();
}
public function getLog() {
return $this->response->getLog();
}
}`
then in a controller, you can make something like this
`/** * Finds and displays a PingMonitor entity. * * @Route("/{id}", name="monitoring.ping_monitor_view", requirements={"id"="\d+"}) * @Template() * @AclAncestor("monitoring.ping_monitor_view") * */ public function viewAction(PingMonitor $ping_monitor) { // Some object with url property $phantom = $this->get('monitoring.phantom'); $phantom->load($ping_monitor->getWebSite()->getUrl() . $ping_monitor->getUrl()); // Some $url
return array(
'log' => $phantom->getLog()
);
}`
finallly {{ dump(log) }} in twig template
But I have found another weird thing but i think its a right problem and not concern this subject. My service work in a custom symfony command (run from the server), but not in a controller, maybe because i use symlink in the bin directory of my project and then a client can't acces to the executable.
My Apologies for my bad english.
Hi Jonnnyw, same problem here... Any solution?
Is this solved, I am stucked with the problem? Any solution?
This is not solved... there are some functios js that not works with phantomjs... My solution to continue was put all content js with try catch, to capture the error and put the error in a div in your html and u will be able to see the error
@saldanha10 , $descriptorspec = array( array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'a') ); I put append instead of write in this section and got worked for the moment but could you suggest more reliable method thanks for your reply, I don't have any custom scripts I am using defaults in the library