Search code examples
phpssluploadibm-cloud-infrastructureobject-storage

PHP Softlayer Object Storage Upload SSL error


Thought I would drop a question, as this is giving me a proper headache

I have a PHP application which uploads files into SoftLayer Object Storage containers. To communicate with the Object Storage API I am using the PHP bindings from https://github.com/softlayer/softlayer-object-storage-php and referenced them from my composer.json file

    "softlayer/objectstorage": "dev-master",

Retrieving object container files and urls is working all fine. But I keep having problems with uploading files though, specially depending on their size. It used to work couple of days ago but some reason stopped working recently

Here is the 'out-of-the-box' code I am using for uploading files:

$options = array('adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 10);
$objStorage = new ObjectStorage('', '', '', $options);

try {
   $newFile = $objStorage->with('RemoteFilePath')
                   ->setLocalFile($PathTolocalFile)
                   ->create();

   return $newFile->getUrl();
}
catch (Exception $e) {
   return $e->getMessage();
}

For some reason, uploading a file that is under 1Mb works. But any file with a size bigger than this, the ->create() request eventually times out, no exception is thrown and I keep getting these error in my log:

xxx.xxx.xxx.xx - [05/06/16 03:47:02] Warning: fwrite(): SSL operation failed with code 1. OpenSSL Error messages:
error:1409F07F:SSL routines:SSL3_WRITE_PENDING:bad write retry (/var/www/vendor/softlayer/objectstorage/lib/ObjectStorage/Http/Adapter/Socket.php:132)

As those bindings are essentially a wrapper round curl, I then tested with CURL myself see if I could upload a file bigger than 1M to Softlayer Storage Container. It turns out it succeeded using CURL both on my dev machine and staging server!

curl -i -XPUT -H "X-Auth-Token: {{MyAuthToken}}" --data-binary "@BigFile.txt" https://lon02.objectstorage.softlayer.net/v1/{{MyAuthTokenKey}}/{{MyContainer}}/BigFile.txt

Have you ever come across this? I don't understand why it suddenly stopped working. Has anyone any idea?

Thanks for reading


Solution

  • I was not able to reproduce your issue, I was able to upload files higher than 2 MB using your code. Anyway, the issue that you have is related to SSL/OpenSSL broken, take a look the following links in order to get more information about it and how to solve it: