PHP taking over 2 minutes to get a response when using https

I've started using the PHP wrapper today with the intention of adding subscribers who become members of my site.
Using HTTPS, It's taking over 2 minutes to get a response. It's fine over http. Here's my snippet of code:

$wrap = new CS_REST_Subscribers($this->config->item('cm_list_id'), $this->config->item('cm_api_key'), 'https', CS_REST_LOG_VERBOSE);
$result = $wrap->add(array(
    'EmailAddress' => $user['email'],
    'Name' => $user['name_first'] . ' ' . $user['name_last'],
    'CustomFields' => array(
            'Key' => 'UserID',
            'Value' => $user['user_id']
    'Resubscribe' => true

Here's the output:


11:12:19 - CS_REST_Subscribers: Creating wrapper for
11:12:19 - CS_REST_Subscribers: Using Socket for transport
11:12:19 - CS_REST_Subscribers: Getting serialiser
11:12:19 - CS_REST_Subscribers: Using native json serialising
11:12:19 - CS_REST_Subscribers: Making POST call to:
11:12:19 - CS_REST_SocketTransport: Creating socket to over https:// for request to /api/v3/subscribers/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.json
11:12:20 - CS_REST_SocketTransport: Sending
POST /api/v3/subscribers/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.json HTTP/1.1
Authorization: Basic NjdkMjJiNjkzMWRkMzM0ODhhY2FkZDMwZDhjMjk1YmU6bm9wYXNz
User-Agent: CS_REST_Wrapper v1.0.1 PHPv5.2.6-1+lenny9 over Socket with native
Content-Type: application/json; charset=utf-8
Content-Length: 128

{"EmailAddress":"","Name":"First Last","CustomFields":[{"Key":"UserID","Value":"36"}],"Resubscribe":true}

down the socket
11:14:29 - CS_REST_SocketTransport: API Call Info for POST 446 bytes uploaded. 673 bytes downloaded
11:14:29 - CS_REST_SocketTransport: Received headers
HTTP/1.1 201 Created
Date: Fri, 24 Dec 2010 00:12:23 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
X-AspNetMvc-Version: 2.0
Cache-Control: private, s-maxage=0
Content-Type: application/json; charset=utf-8
Content-Length: 21

11:14:29 - CS_REST_SocketTransport: Got HTTP Status Code: 201
11:14:29 - CS_REST_Subscribers: Call result:
A PHP Error was encountered

Severity: Warning
Message:  fpassthru() [function.fpassthru]: SSL: Connection reset by peer
Filename: class/transport.php
Line Number: 133


If I change the the API call to use 'http', the result, while still a bit slow (over 2 seconds), it is dramatically faster. Manually loading a URL like "" in my browser renders very quickly.

Where would I look to resolve this?

Also, I'm unable to find any list of server requirements for the PHP wrapper. I install curl and php5-curl. Is there anything else required? Shouldn't this be documented somewhere?


tobyb tobyb, 5 years ago

Hi jaydisc,

Sorry for the delay, we've tried to reduce any requirements in the PHP wrapper, any default PHP installation should be fine. Based on your output it doesn't look like you've correctly installed cURL (it's using a raw socket rather than the cURL extension). Have you followed the instructions here:

We've seen these delays before when writing over the socket however usually setting the stream timeout eliminates the issue (which the wrapper is doing). I'd start out with getting cURL to work and the wrapper should work correctly.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free