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

Works in Localhost does not work in webserver #235

Open
sriducati opened this issue Aug 26, 2016 · 2 comments · May be fixed by #258
Open

Works in Localhost does not work in webserver #235

sriducati opened this issue Aug 26, 2016 · 2 comments · May be fixed by #258

Comments

@sriducati
Copy link

sriducati commented Aug 26, 2016

I am trying to fetch contents from

https://some.com/suggestions.php?q=kann

include('./Request/library/Requests.php');
Requests::register_autoloader();
$request = Requests::get('https://some.com/suggestions.php?q=kann',array('Accept' => 'application/json'));
echo json_encode($request->body);

Above code works fine when we run on localHost But I get

"500 Internal server error

PhP Error Shows

`

Fatal error: Uncaught exception 'Requests_Exception' with message 'cURL error 28: Operation timed out after 10000 milliseconds with 0 bytes received' in /home/admin/domains/domain.com/public_html/Request/library/Requests/Transport/cURL.php:277 Stack trace: #0 /home/admin/domains/domain.com/public_html/Request/library/Requests/Transport/cURL.php(120): Requests_Transport_cURL->process_response(false, Array) #1 /home/admin/domains/domain.com/public_html/Request/library/Requests.php(317): Requests_Transport_cURL->request('https://some.com...', Array, NULL, Array) #2 /home/admin/domains/domain.com/public_html/Request/library/Requests.php(194): Requests::request('https://some.com...', Array, NULL, 'GET', Array) #3 /home/admin/domains/domain.com/public_html/Request/examples/get.php(14): Requests::get('https://some.com...', Array) #4 {main} thrown in /home/admin/domains/domain.com/public_html/Request/library/Requests/Transport/cURL.php on line 277

`

when run on webserver, is there any way to fix this?

@sriducati sriducati changed the title Works in Localhost doe snot work in webserver Works in Localhost doeS not work in webserver Aug 26, 2016
@sriducati sriducati changed the title Works in Localhost doeS not work in webserver Works in Localhost does not work in webserver Aug 26, 2016
@ramesh-tr
Copy link

Are you running your code behind a firewall or proxy on the web server?

@allanlaal
Copy link

allanlaal commented Dec 14, 2016

the remote server is probably using a newer TLS version than your webservers cURL supports (i.e. TLS v1.2).

If you are unable to update the webservers cURL, then set Requests_Transport_fsockopen as the preferred transport method with Requests::add_transport.

include('./Request/library/Requests.php');
Requests::register_autoloader();
Requests::add_transport('Requests_Transport_fsockopen')
$request = Requests::get('https://some.com/suggestions.php?q=kann',array('Accept' => 'application/json'));
echo json_encode($request->body);

Sadly overriding the preferred transport method does not work in this library (yet), so I forked my own and fixed Requests::add_transport() there:
https://github.com/allanlaal/Requests

I've iniated a pull request too:
#258

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

Successfully merging a pull request may close this issue.

3 participants