Zend 2 Http Client Request times out when requesting php file from localhost/public directory

大兔子大兔子 提交于 2019-12-08 12:15:44

问题


The below http-request issued from an Zend Controller Action towards localhost fails with a timeout. My guess is that I have missed a very basic concept, since a request to an outside uri (e.g. www.google.com) returns normally.

Of course the URL below ($localUrl) does return the expected result (TEST) when pasted directly into the browser.

I am using Zend Framework 2 (based on the current skelleton application - today: 2016/06/19) in an XAMPP 3.2.2 Windows (Developer Environment) with PHP 5.6.21 and xdebug enabled.

update 1

I've debugged a bit deeper now:

When the request is sent, the programm is stuck for the duration of the timeout.

After that I get a "Zend\Http\Client\Adapter\Exception\TimeoutException".

Following that the code inside the debugger jumps into the php script requested (checklogin.php) which I have filled with with just an echo statement for simplicity.

After that, instead of continuing returning the result in the Action function the script stops and I get presented with the Timeout Exception Errorpage.

Please do not read too much into the code for now, since it does not properly handle the result yet.

namespace MyModule\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Http\Client;

class PhpbbAuthController extends AbstractActionController{

public function checkAction(){
    $localUrl = 'http://localhost/zendproject/public/phpbbauth/checklogin.php';

    $client = new Client($localUrl , array(
      'maxredirects' => 0,
      'timeout'      => 10
    ));
    $response = $client->send();

    return new ViewModel(array('content'=>$response->getContent()));
}

}

update 2

Content of checklogin.php

<?php
echo "TEST";
?>

Small Note: There are very likely far better sollutions for my overall problem, which is integrating a zend application into the PHPBB3 Authentication of an existing Forum, but including this here would go beyond the scope of this question.

来源:https://stackoverflow.com/questions/37905866/zend-2-http-client-request-times-out-when-requesting-php-file-from-localhost-pub

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!