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

Implementation of external requests in Minion Task #678

Closed
entermix opened this issue Apr 19, 2016 · 5 comments
Closed

Implementation of external requests in Minion Task #678

entermix opened this issue Apr 19, 2016 · 5 comments

Comments

@entermix
Copy link

entermix commented Apr 19, 2016

Hello everybody! When the external request, for example:

$request = Request::factory('http://example.com/post_api') ->method(Request::POST) ->post(array('foo' => 'bar', 'bar' => 'baz'));

I get an error:

Request_Exception [ 0 ]: Error fetching remote /sys/send.php [ status 0 ] Failure when receiving data from the peer ~ SYSPATH/classes/Kohana/Request/Client/Curl.php [ 102 ]

Why is that? file_get_contents () function works without problems

@entermix entermix changed the title Implementation of external requests Implementation of external requests in Minion Task Apr 19, 2016
@WinterSilence
Copy link

Minion_Task work in CLI, it`s not HTTP!

@acoulton
Copy link
Member

@WinterSilence has misunderstood your problem. This is about sending HTTP requests to some other URL from a Minion_Task, not receiving them.

Unfortunately you haven't given enough information for us to help you:

  • Do you have the same problem if you try to make that request from a web process (eg from a controller) or is this specific to minion?
  • What is the URL you are requesting from? The error message looks like you're trying to request from /sys/send.php - are you providing a full absolute URL?
  • Can you send a request to that URL with command-line curl and get a successful response?

Also I would strongly support @shadowhand's advice on your other ticket that Kohana's external request / curl code is not very robust and it would be much better if you used Guzzle or another library designed specifically for making HTTP requests.

@entermix
Copy link
Author

entermix commented Apr 20, 2016

@WinterSilence
Why then runs file_get_contents and curl?

@acoulton

I'm trying to make an outside inquiry From inside the Mini Task

file_get_contents('http://example.com/');- OK

    function request($url, $method = 'GET', $fields = [])
    {
        curl_setopt_array($this->_ch, [
            CURLOPT_USERAGENT => 'Example UA',
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLOPT_SSL_VERIFYPEER => FALSE,
            CURLOPT_POST => ($method == 'POST'),
            CURLOPT_POSTFIELDS => $fields,
            CURLOPT_URL => $url,
        ]);

        return curl_exec($this->_ch);
    }

$request = request('http://example.com/', 'GET', []);- OK

$request = Request::factory('http://example.com/')->method(Request::GET)->execute()->body(); -

Request_Exception [ 0 ]: Error fetching remote /sys/send.php [ status 0 ] Failure when receiving data from the peer ~ SYSPATH/classes/Kohana/Request/Client/Curl.php [ 102 ]

@acoulton
Copy link
Member

@entermix sorry you've not answered my questions:

What happens if you use exactly the same Request::factory() code to send the request to the same URL from a controller action - is this minion/CLI specific or does it happen from web code as well?

What is the URL you're requesting? Is /sys/send.php part of the URL? If not, is that file on your system and what is it? The error message shows that's the URL curl is trying to reach - that value doesn't come from anywhere in kohana so it must be coming from your system somewhere.

@entermix
Copy link
Author

@acoulton thank you so much! The problem was really in the URL, thanks again!

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

No branches or pull requests

3 participants