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

Receiving cURL error at random times #19

Closed
mferreira92 opened this issue Oct 5, 2016 · 11 comments
Closed

Receiving cURL error at random times #19

mferreira92 opened this issue Oct 5, 2016 · 11 comments

Comments

@mferreira92
Copy link

Hi,

Ive been using this great tool since i discovered it a couple of days ago. Everything went fine, except today.

Some random times (doing the same task) I'm getting random cURL error, or a message saying "Bad Request".

The cURL error is the following:
cURL error 56: SSL read: error:00000000:lib(0):func(0):reason(0), errno 104 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

I have seen a closed issue similar to mine, but the workaround was to disable https.

If i refresh the browser, the error goes away, and its totally random. I'm doing a simple task (e.g. listng cards from a board).

Can you please help me? I'm available to give some debug info.. Just let me know what do you need.

@stevenmaguire
Copy link
Owner

This issue is typically related to networking issues either in your infrastructure, or perhaps Trello's network. The issues do come up from time to time and from my research there is no code change evident that will fix the issue, so I typically close the issues.

The issue you mentioned that offers a work around of not using HTTPS is not recommended by me. That choice was made by the issue's author. I suggest investigating any possible network configuration.

Having said that, if you discover that there is some code change that needs to be made, I am happy to consider it. This package has been downloaded and installed over 2,000 times and this issue's frequency does not correlate with that volume.

@joesken
Copy link

joesken commented Oct 15, 2016

Hi Steven,

Just to let you know that I am having this (or very similar issue also). I'm sure it is somehow related to my local setup but I can't find a fix after reading through everything I could find.

Catching the error as you advised in a similar issue and printing it out however was interesting as it does actually complete the call and the data is returned. See below. Changing to http:// as the domain likewise removes the issue but obviously I'd rather not.

Just posting it here in case it gives any insight and/or is useful to anyone else.

Calling this:
try {
$boards = $client->getCurrentUserBoards();
} catch (Stevenmaguire\Services\Trello\Exceptions\Exception $e) {
print ('Catch Statement'.PHP_EOL);
$code = $e->getCode(); // Http status code from response
$reason = $e->getMessage(); // Http status reason phrase
$error = $e->getPrevious(); // GuzzleHttp\Exception\RequestException from http client
$body = $e->getResponseBody(); // stdClass response body from http client
print('code' . $code . PHP_EOL);
print('reason' . $reason . PHP_EOL);
print('error' . $error . PHP_EOL);
print('body' . $body . PHP_EOL);
}

I get:

`/usr/bin/php5 /home/joes/dev.local/maintenance-maker/test.php
Catch Statement
code200
reasonOK
errorexception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 56: SSL read: error:00000000:lib(0):func(0):reason(0), errno 104 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:187
Stack trace:
#0 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)
#1 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#2 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#3 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(28): GuzzleHttp\Handler\CurlHandler->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#4 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(51): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#5 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(42): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#6 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/Middleware.php(30): GuzzleHttp\PrepareBodyMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#7 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(68): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#8 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/Middleware.php(59): GuzzleHttp\RedirectMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#9 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/HandlerStack.php(67): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#10 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/Client.php(275): GuzzleHttp\HandlerStack->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#11 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/Client.php(98): GuzzleHttp\Client->transfer(Object(GuzzleHttp\Psr7\Request), Array)
#12 /home/joes/dev.local/maintenance-maker/vendor/guzzlehttp/guzzle/src/Client.php(104): GuzzleHttp\Client->sendAsync(Object(GuzzleHttp\Psr7\Request), Array)
#13 /home/joes/dev.local/maintenance-maker/vendor/stevenmaguire/trello-php/src/Http.php(236): GuzzleHttp\Client->send(Object(GuzzleHttp\Psr7\Request), Array)
#14 /home/joes/dev.local/maintenance-maker/vendor/stevenmaguire/trello-php/src/Http.php(112): Stevenmaguire\Services\Trello\Http->sendRequest(Object(GuzzleHttp\Psr7\Request))
#15 [internal function]: Stevenmaguire\Services\Trello\Http->get('members/my/boar...')
#16 /home/joes/dev.local/maintenance-maker/vendor/stevenmaguire/trello-php/src/Traits/ApiMethodsTrait.php(378): call_user_func_array(Array, Array)
#17 /home/joes/dev.local/maintenance-maker/test.php(19): Stevenmaguire\Services\Trello\Client->__call('getCurrentUserB...', Array)
#18 /home/joes/dev.local/maintenance-maker/test.php(19): Stevenmaguire\Services\Trello\Client->getCurrentUserBoards()
#19 {main}
body[{"name":"2015","desc":"","descData":null,"closed":true,"idOrganization":....Full list of boards is returned here...

Process finished with exit code 0
`

Cheers.

Joe

@iamroi
Copy link

iamroi commented Oct 19, 2016

Hi @mferreira92 ,

Today I have found that using 'domain' => 'https://api.trello.com' instead of https://trello.com is working way better! Let me know if this change working for you.
@stevenmaguire FYI

@mferreira92
Copy link
Author

Hi @mrajabtech ,

Thank you for the info. On my quest to solve this I've also tested this link but noticed no major improvements. I've also recompilerd curl to the latest version and no luck either.

I had the exact same error you are having and also the same error that another person was having, but this issue was closed without any hesitation, so I built my own (simple) implementation and I never had any error again.

I believe that this is not a problem directly related with @stevenmaguire implementaiton, but must be something by some module that it's using. Perhaps a larger timeout would fit, but I tested all these options, I even edited code of some modules, but no luck either.

this might be related with the Linux distro I'm using (Ubuntu) or some modules that I have installed, altough I've upgraded curl to the latest version.

@iamroi
Copy link

iamroi commented Oct 19, 2016

Hi @mferreira92, Thanks for getting back! I am using Amazon EC2 Linux with Bitnami LAMPstack-5.6 and updated every piece I can possible and tried all the things you have mentioned but no luck.

It is so weird that it works but fails at very random times. I am using Google, Slack API clients and this one altogether in my application(all of these clients using Guzzle module) and never had any issue like this with them. Could it be because some other PHP library interfering? @stevenmaguire

Think am going to write a simple API wrapper just like you and give it a try and hope someone can find whats causing this meanwhile.

@joesken
Copy link

joesken commented Oct 19, 2016

Hi @mrajabtech no luck here changing the URL either I'm afraid. Currently I can only get it to work consistently by using the insecure URL for get requests (e.g. getBoardCards) and the secure URL for post actions (e.g. addCard).

I'm using Ubuntu 15.04 (3.19), PHP 5.6.4, curl 7.38.0 (x86_64-pc-linux-gnu) libcurl/7.38.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3

@stevenmaguire
Copy link
Owner

Have you explored possible configuration issues with the peer verification certificate on your machines? (http://docs.guzzlephp.org/en/latest/request-options.html#verify)

This library uses Guzzle v6, which is a very reliable library. I would encourage you explore the peer verification option as a potential solution. You can new up your own instance of GuzzleHttp\Client with your verification settings and use the existing package configuration to replace the stock HttpClient.

$httpClient = new \GuzzleHttp\Client($yourHttpClientOptions);

$trelloClient = new \Stevenmaguire\Services\Trello\Client($yourTrelloClientOptions);

$trelloClient->setHttpClient($httpClient);

// attempt your requests

If this proves to be effective in resolving your issues, I will look to adding an optional configuration item that expects you to pass the local SSL CA certificate path as a parameter.

Additionally, in response to the comments:

I believe that this is not a problem directly related with @stevenmaguire implementaiton, but must be something by some module that it's using.

Could it be because some other PHP library interfering?

This package is dependent on only two other libraries "guzzlehttp/guzzle": "^6.0" and "league/oauth1-client": "^1.5".

I am using Google, Slack API clients and this one altogether in my application(all of these clients using Guzzle module) and never had any issue like this with them.

There is no reason to expect that different companies providing different service resources will have the exact same technical expectations.

@stevenmaguire
Copy link
Owner

@mferreira92 @joesken @mrajabtech did you have any luck with my previous suggestion? Does the project need to be updated to include optional configuration for local ssl certificate paths?

@stevenmaguire
Copy link
Owner

Trying again...

@mferreira92 @joesken @mrajabtech did you have any luck with my previous suggestion?

@iamroi
Copy link

iamroi commented Nov 15, 2016

Hi @stevenmaguire, Sorry I just got back from a vacation.

I tried your suggestion replacing stock HttpClient with the configuration for local ssl certificate path but still no luck.

I have made a little tweak in the code to make it work consistently as @joesken suggested that

Currently I can only get it to work consistently by using the insecure URL for get requests (e.g. getBoardCards) and the secure URL for post actions (e.g. addCard).

https://github.com/mrajabtech/trello-php/commit/246155a9ef8ad7da3304fb7ce35a85453006ee1e

@mferreira92 please let me know if @stevenmaguire's suggestion worked for you. Thanks.

@bzhang4sacstate
Copy link

I am having the same problem. Looks like the tweak @mferreira92 did worked.

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

No branches or pull requests

5 participants