OpenBuildings/spiderling

'Curl "url" throws exception Failed to connect to localhost port 4894: Connection refused'

Opened this issue · 6 comments

use Openbuildings\Spiderling\Page;
use Openbuildings\Spiderling\Driver_Phantomjs;
$page = new Page(new Driver_Phantomjs);

PHP Fatal error:  Uncaught exception 'Openbuildings\Spiderling\Exception_Driver' with message 'Curl "url" throws exception Failed to connect to localhost port 4894: Connection refused' in /ROOT/www/github/spiderling/src/Openbuildings/Spiderling/Driver/Phantomjs/Connection.php:263
Stack trace:
#0 /ROOT/www/github/spiderling/src/Openbuildings/Spiderling/Driver/Phantomjs/Connection.php(209): Openbuildings\Spiderling\Driver_Phantomjs_Connection->call('url', Array)
#1 /ROOT/www/github/spiderling/src/Openbuildings/Spiderling/Driver/Phantomjs.php(281): Openbuildings\Spiderling\Driver_Phantomjs_Connection->post('url', Array)
#2 /ROOT/www/github/spiderling/src/Openbuildings/Spiderling/Page.php(33): Openbuildings\Spiderling\Driver_Phantomjs->visit('http://www.xiam...', Array)
#3 /ROOT/www/github/spiderling/apps/index.php(9): Openbuildings\Spiderling\Page->visit('http://www.xiam...')
#4 {main}
  thrown in /ROOT/www/github/spiderling/src/Openbuildings/Spiderling/Driver/Phantomjs/Connection.php on line 263

Hi @maojindao55, we get this kind of error on Travis CI occasionally as well. It seems like a timeout issue from PhantomJS. If you're getting it every time it's possible you have a remote asset in the page which PhantomJS is trying to load. For faster experience try to not have slow assets (or no remote assets at all) in the pages loaded through PhantomJS.

BTW if you're using spiderling for integration/functional testing, have a look at our phpunit-spiderling package.

Hi @hkdobrev , this is my full code, is the target url some problem? how can I change my code? thx!

<?php                                                                                                         

require_once __DIR__.'/../tests/bootstrap.php';                                                               
use Openbuildings\Spiderling\Page;                                                                            
use Openbuildings\Spiderling\Driver_Phantomjs;                                                                

$page = new Page(new Driver_Phantomjs);                                                                       

$page->visit('http://www.xiamp4.com/Html/GP21538.html');                                                      

//echo $page->find('div.info > h1')->text();                                                                  
echo $page->find('span > a.d5')->text();

@hkdobrev I think you said "For faster experience try to not have slow assets (or no remote assets at all) in the pages loaded through PhantomJS." is not the better solution, because assets is out of our control!

Well, Spiderling was initially created for integration testing and based on your previous issue I thought you're trying to access your own pages.

I'd try to have a look at the problems you're having on this page later this week.

Cheers!

On Wed, Sep 23, 2015, 00:45 maojindao55 notifications@github.com wrote:

@hkdobrev https://github.com/hkdobrev I think you said "For faster
experience try to not have slow assets (or no remote assets at all) in the
pages loaded through PhantomJS." is not the better solution, because assets
is out of our control!


Reply to this email directly or view it on GitHub
#14 (comment)
.

hi @hkdobrev , what is about this problem?

@maojindao55: I appreciate this is an old question, but support issues of this kind are probably best directed to Stack Overflow (or similar).