Amazon S3 - deleteObjects() - "guzzle" errors? - php

Here's the reduced but accurate code I'm working with.
$client = S3Client::factory(array('key'=>$ak,'secret'=>$sk));
foreach(range(1,10) as $i) $temp[] = array('Key'=>$i);
$result = $client->deleteObjects(array('Bucket'=>'bucket','Objects'=>$temp));
return $result;
Everything works, it deletes the objects as requested but it throws all of these errors from the phar file. Running this locally as you can see below.
Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 56: Problem (2) in the Chunked-Encoded data [url] https://bucket.s3.amazonaws.com?delete=' in phar://C:/wamp/www/bucket/local/aws.phar/Aws/Common/Client/AbstractClient.php on line 285
Guzzle\Http\Exception\CurlException: [curl] 56: Problem (2) in the Chunked-Encoded data [url] https://bucket.s3.amazonaws.com?delete= in phar://C:/wamp/www/bucket/local/aws.phar/Guzzle/Http/Curl/CurlMulti.php on line 365
Aws\Common\Exception\TransferException: [curl] 56: Problem (2) in the Chunked-Encoded data [url] https://bucket.s3.amazonaws.com?delete= in phar://C:/wamp/www/bucket/local/aws.phar/Aws/Common/Client/AbstractClient.php on line 285

I was also having this problem running WampServer on Windows 7 x64. Through dumb luck, I just stumbled across the solution.
Simply add 'scheme' => 'http' to the factory config settings and it starts working!

Little late I realize, but searches for this returned very little, hopefully this might help someone else.
I was also getting this error only when trying to deleteObjects, WAMPSERVER (64 BITS & PHP 5.4) 2.4, Windows 7 x64. I think something is wrong with the Curl extension in this version of WAMP. I installed WAMPSERVER (32BITS & PHP 5.4) 2.4 and had no issues with deleteObjects.

Possible solution is to add
'curl.options' => array('CURLOPT_HTTP_VERSION'=>'CURL_HTTP_VERSION_1_0')
to S3Client::factory options.
No more mentioned curl errors, but now I sometimes receive Simple XML error: "Entity: line 2: parser error : Extra content at the end of the document".

Related

How to fix SOAP-ERROR parsing wsdl in php 7

I am migrating my application from php 5 to php 7.2.
I have a problem with theSoapclient call knowing that it works correctly with php 5.
After a lot of research I am progressing on my soapClient script with php 7.2, but I have a concern for stability.
The script will load the wsdl a few times, like 1 time out of 40 and then indicate a loading problem.
[message:protected] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://ip?WSDL' : failed to load external entity "http://ip?WSDL"
I added the stream_context , cache_wsdl options but no stable result!
it worked twice with this code bellow
$option = array (
'location' => $optionSc['location'],
'uri' => $optionSc['location'],
'login' => $optionSc['login'],
'password' => $optionSc['password'],
'trace' => 1,
'connection_timeout' => 0,
'exceptions' => 1
);
after that it returns like I described first.
anyone can help me with that if he fixed this problem I did a lot of researches but nothing is working fine and I am relly blocked!
I've experienced a similar behaviour. PHP was reporting errors with parsing remote WSDL.
The problem was weak certificate used by the remote server that kept being refused by OpenSSL, even before being processed by PHP.
Problem
I have confirmed this by trying to download the WSDL using curl
curl REMOTE_ADDRESS
which reported the following error
error:14082174:SSL routines:SSL3_CHECK_CERT_AND_ALGORITHM:dh key too small.
The diffie-hellman key base was 1024 instead of recommended 2048 which I checked using openssl command (see https://weakdh.org/)
openssl s_client -showcerts -connect admonitoring.mediaresearch.cz:443 </dev/null
Solution
Until the certificate problem is fixed and a new one, more secure, issued, I have managed to fix this problem by temporarily lowering Openssl security settings.
In /etc/ssl/openssl.cnf (Debian) comment out the following line
# comment out the following line in /etc/ssl/openssl.cnf
CipherString = DEFAULT#SECLEVEL=2
# or set SECLEVEL to 1
CipherString = DEFAULT#SECLEVEL=1
Instead of changing the settings on the whole system, I solved it by using:
$options['ssl']['ciphers'] = 'DEFAULT#SECLEVEL=1';
in the stream_context

Symfony panter: getting error unknown error: failed to write prefs file from facebook/webdriver

I have build a webcrawler for a client in Laravel. To accomplish this i use the symfony panter package. symfony panter
I finished developing it and have been asked to put it on the server of the client, which is where the errors occur.
It was working perfectly fine on my homestead vagrant box. Ofcourse to accomplish this I installed chrome78 on the vagrant box and used the chromedriver-bin/update.sh from the panter package so it supports chrome78. This worked like a charm.
So as mentioned, I have to install the package on a client's server, which is running on CentOS 7. I installed chrome on it using this tutorial:
https://www.cyberciti.biz/faq/howto-install-google-chrome-on-redhat-rhel-fedora-centos-linux/
Ofcourse, i again ran the ./update.sh from the panter package. I now expected it to work. But I am getting the following error.
Facebook\WebDriver\Exception\UnknownServerException : unknown error: failed to write prefs file
(Driver info: chromedriver=78.0.3904.105 (60e2d8774a8151efa6a00b1f358371b1e0e07ee2-refs/branch-heads/3904#{#877}),platform=Linux 2.6.32-042stab136.1 x86_64)
at /home/tsm/domains/thesilvermountain.nl/public_html/laravel-app/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:114
110| throw new ElementNotVisibleException($message, $results);
111| case 12:
112| throw new InvalidElementStateException($message, $results);
113| case 13:
> 114| throw new UnknownServerException($message, $results);
115| case 14:
116| throw new ExpectedException($message, $results);
117| case 15:
118| throw new ElementNotSelectableException($message, $results);
Exception trace:
1 Facebook\WebDriver\Exception\WebDriverException::throwException("unknown error: failed to write prefs file
(Driver info: chromedriver=78.0.3904.105 (60e2d8774a8151efa6a00b1f358371b1e0e07ee2-refs/branch-heads/3904#{#877}),platform=Linux 2.6.32-042stab136.1 x86_64)", ["5c7df90c615886c0b1406dd58935e9f4"])
/home/tsm/domains/thesilvermountain.nl/public_html/laravel-app/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:331
2 Facebook\WebDriver\Remote\HttpCommandExecutor::execute(Object(Facebook\WebDriver\Remote\WebDriverCommand))
/home/tsm/domains/thesilvermountain.nl/public_html/laravel-app/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:144
Please use the argument -v to see more details.
I have seen similar posts regarding different applications. But they do not provide me with the how-to or information to fix this particular issue. If someone has an idea, could they please help me out? I will be checking on this post regularly, so if any follow-up questions need answering I will try to respond quick!
With kind regards

Is there a version of PSWebServiceLibrary.php running with PHP v7.0?

I have site A that runs on Prestashop 1.6.1.5 and to retrieve data on another site (site B) which also runs under Prestashop 1.6.1.5, I use a module "homemade" (by my predecessor) which uses, among other things, PSWebServiceLibrary.php.
When I change version of PHP (from version 5.6 to version 7.0) on site B and I want to use the module on site A, I have some errors including PSWebServiceLibrary.php
I thus have the following error message:
Fatal error: Uncaught exception 'PrestaShopWebserviceException' with message
'This call to PrestaShop Web Services failed and returned an HTTP status of 500. That means: Internal Server Error.' in www.ndd.fr/PSWebServiceLibrary.php:95
Stack trace:
0 www.ndd.fr/PSWebServiceLibrary.php(297): PrestaShopWebservice->checkStatusCode(500)
1 www.ndd.fr/modules/orderlist/classes/orderArrayCreator.class.php(145): PrestaShopWebservice->get(Array)
2 www.ndd.fr/modules/orderlist/controllers/admin/AdminOrderList.php(125): orderArrayCreator->createDistantOrderArray()
3 www.ndd.fr/classes/controller/Controller.php(178): AdminOrderListController->postProcess()
4 www.ndd.fr/override/classes/Dispatcher.php(335): ControllerCore->run()
5 www.ndd.fr/override/classes/Dispatcher.php(107): Dispatcher->dispatch_16()
6 www.ndd.fr/admin/index.php(58): Dispatcher->dispatch()
7 {main} thrown in www.ndd.fr/PSWebServiceLibrary.php on line 95
If I come back to version 5.6, I have no problem, the module works normally.
So this is a problem related to version 7 of PHP.
Is there a version of PSWebServiceLibrary.php that works with PHP v 7.0?
In advance thank you for your help because I am a beginner in PHP
Indeed PrestaShop 1.6.1.5 is not officially PHP 7.x compatible, however, you should be able to fix this error easily:
Edit the file /classes/webservice/WebserviceRequest.php and on line 794 replace:
if (count(self::$shopIDs)) {
by
if (is_array(self::$shopIDs) && count(self::$shopIDs)) {
Download the latest version of PSWebServiceLibrary.php (here)
To make sure everything's now ok, create a new file test-ws.php with the following code (and type in your url/credentials) :
<?php
require_once('./PSWebServiceLibrary.php');
try
{
$ws = new PrestaShopWebservice('http://www.yourstore.com', 'YOURWSKEYHERE', false);
echo '<pre>';
print_r($ws);
}
catch (PrestaShopWebserviceException $ex)
{
echo 'Error : '.$ex->getMessage();
}
?>
If it works you should get something like:
PrestaShopWebservice Object
(
[url:protected] => http://www.yourstore.com
[key:protected] => YOURWSKEYHERE
[debug:protected] =>
[version:protected] => unknown
)
In case you still get a 500 error after that: Turn on error_logs in your php.ini configuration file and check the errors logs. Alternately, you can try to set _PS_MODE_DEV_ to true in /config/defines.inc.php.

SoapClient failing to load WSDL, needs apache restart to work again

Server is CENTOS with PHP 5.4 and Apache 2.2.
I have a SoapClient object like this:
$client = new \SoapClient(__DIR__ . "/wsdlfilehere.wsdl", array("soap_version"=>SOAP_1_2, "trace"=>true));
After awhile (within 24 hours), this code throws an error:
SOAP-ERROR: Parsing WSDL: Couldn't load from '/wsdlfilehere.wsdl' : failed to load external entity "/wsdlfilehere.wsdl".
Then after I restart apache and it works again.
Edit: even setting cache_wsdl to WSDL_CACHE_NONE doesn't fix the issue.
After digging around I finally found a workaround/solution.
Following this link on Ubuntu's launchpad it seems that other people are also experiencing this problem. I followed zabuch's instruction at comment #6 and it seems to work now. I agree with him that the issue might be on mod_php/php itself and not Ubuntu only, since I'm on CentOS and have experienced this problem.
From zabuch's comment:
The workaround for the issue is to add this:
libxml_disable_entity_loader(false);
before creating new SoapClient.

PHP in TOMCAT 6 - Exception

I have been trying to integrate PHP in APACHE TOMCAT 6 by following second answer for the QUESTION RUN PHP APP IN TOMCAT 6. I am facing troubles with the configuration.
First I got Exception java.lang.UnsatisfiedLinkError: no php5srvlt in java.library.path. which I resolved by placing php5srvlt.jar, generated in step 12, in tomcat\lib.
After that I am facing
java.lang.UnsatisfiedLinkError: net.php.servlet.send(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Z)V
net.php.servlet.send(Native Method)
net.php.servlet.service(servlet.java:190)
net.php.servlet.service(servlet.java:214)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
Exception.
I tried to find solutions for this but could only get close to this QUESTION. But, I do not want to do the whole thing once again, because I have tried several times. I tried with TOMCAT 8.0.15, but failed. Now, just to go in sink with the instructions I have installed TOMCAT 6 and trying to integrate PHP.
I am placing log file for the request made for tomcat/webapps/PHP/test.php.
LOCALHOST.YYYY-MM-DD.log
Dec 29, 2014 12:15:46 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet php threw exception
java.lang.UnsatisfiedLinkError: net.php.servlet.send(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Z)V
at net.php.servlet.send(Native Method)
at net.php.servlet.service(servlet.java:190)
at net.php.servlet.service(servlet.java:214)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1778)
at java.lang.Thread.run(Thread.java:744)
TEST.PHP
<?php
echo "HELLO WORLD";
?>
EDIT
I mistook that I was getting problem 1 because i did not have php5srvlt.jar in tomcat/lib. But, in fact, problem 1 appears when i request the page for the first time after starting the server. and later on I see problem 2.
I've learned from here that php and pecl version must be same, but still I get the same error even after working with same version numbers 5.2.5
The error message indicates that you're missing .dll-files necessary for such a .. fragile contraption.
The UnsatisfiedLinkError is thrown when an application attempts to load a native library like .so in Linux, .dll on Windows or .dylib in Mac and that library does not exist.
But please - reconsider what you're actually doing. There is (almost) no good reason for running a PHP context inside Tomcat.

Categories