Title: stream_socket_client()
Last modified: August 31, 2016

---

# stream_socket_client()

 *  Resolved [aiopa](https://wordpress.org/support/users/aiopa/)
 * (@aiopa)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/stream_socket_client/)
 * Hallo. I am having some issues with stream_socket_client()
 * Error msg when debug true:
    Warning: stream_socket_client(): unable to connect
   to ssl://shop.mysite.no:443 (Connection timed out) in /var/www/shop.mysite.no/
   dist/wp-includes/class-wp-http-streams.php on line 150
 * I have a feeling this is a server error, but i cant find a solution. The server
   is self hosted Debian 8.1 LAMP, Curl, openSSl. This is no local host, live site
   that is out with https enabled and forced.
 * Does anyone know how I can fix this?
 * [https://wordpress.org/plugins/wp-pdf-templates/](https://wordpress.org/plugins/wp-pdf-templates/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Thread Starter [aiopa](https://wordpress.org/support/users/aiopa/)
 * (@aiopa)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/stream_socket_client/#post-7217816)
 * Found some more Errors:
 * /pdf
    gives error: Failed to load PDF document
 * /pdf-preview
    gives error:
 * Warning: file_get_contents([https://localhost/produkt/twizy-leasing/?pdf-template](https://localhost/produkt/twizy-leasing/?pdf-template)):
   failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /var/
   www/xxx/dist/wp-content/plugins/wp-pdf-templates/wp-pdf-templates.php on line
   243
 * Warning: file_get_contents([http://localhost/produkt/twizy-leasing/?pdf-template](http://localhost/produkt/twizy-leasing/?pdf-template)):
   failed to open stream: Connection timed out in /var/www/xxx/dist/wp-content/plugins/
   wp-pdf-templates/wp-pdf-templates.php on line 247
 * Warning: file_get_contents([https://xxx/produkt/twizy-leasing/?pdf-template](https://xxx/produkt/twizy-leasing/?pdf-template)):
   failed to open stream: Connection timed out in /var/www/xxx/dist/wp-content/plugins/
   wp-pdf-templates/wp-pdf-templates.php on line 254
 *  Thread Starter [aiopa](https://wordpress.org/support/users/aiopa/)
 * (@aiopa)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/stream_socket_client/#post-7217941)
 * So i solved my problem by using cURL, I added this
 *     ```
       function curl_get_contents($url) {
           $ch = curl_init();
   
           curl_setopt($ch, CURLOPT_HEADER, 0);
           curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
           curl_setopt($ch, CURLOPT_URL, $url);
   
           $data = curl_exec($ch);
           curl_close($ch);
   
           return $data;
       }
       ```
   
 * And changed
    `$html = file_get_contents( $link, false, $context );`
 * `$html = file_get_contents( str_ireplace( 'https://', 'http://', $link ), false,
   $context );`
 * `$html = file_get_contents( $link , false, $context );`
 * To
    `$html = curl_get_contents( $link );`
 * `$html = curl_get_contents( str_ireplace( 'https://', 'http://', $link ) );`
 * `$html = curl_get_contents( $link );`
 *  [Kris](https://wordpress.org/support/users/forumfan/)
 * (@forumfan)
 * [10 years ago](https://wordpress.org/support/topic/stream_socket_client/#post-7218129)
 * Please where (file name and path) you made this change.
 *  Thread Starter [aiopa](https://wordpress.org/support/users/aiopa/)
 * (@aiopa)
 * [10 years ago](https://wordpress.org/support/topic/stream_socket_client/#post-7218130)
 * File:
    /wp-content/plugins/wp-pdf-templates/wp-pdf-templates.php
 * And remember to backup this file!!
 *  [Kris](https://wordpress.org/support/users/forumfan/)
 * (@forumfan)
 * [10 years ago](https://wordpress.org/support/topic/stream_socket_client/#post-7218131)
 * The problem is that I don’t have this template and this path.
 * Warning: stream_socket_client(): unable to connect to tcp://page (Connection 
   refused) in /var/www/html/wordpress/wp-includes/class-wp-http-streams.php on 
   line 150
 * This warning is only first time after you load web page at first time in current
   browser session. When you close browser and open again wordpress this warning
   is coming again ;-(
 *  [Kris](https://wordpress.org/support/users/forumfan/)
 * (@forumfan)
 * [10 years ago](https://wordpress.org/support/topic/stream_socket_client/#post-7218132)
 * Success !
    After updating theme problem solved 😉 Thx!
 *  Plugin Author [Viljami Kuosmanen](https://wordpress.org/support/users/zuige/)
 * (@zuige)
 * [10 years ago](https://wordpress.org/support/topic/stream_socket_client/#post-7218133)
 * It’s good to hear you were able to fix the issue.
 * I don’t think we’re moving to curl any time soon due to curl-support missing 
   on some hosting platforms.
 * Closing issue now.
 *  [Kris](https://wordpress.org/support/users/forumfan/)
 * (@forumfan)
 * [10 years ago](https://wordpress.org/support/topic/stream_socket_client/#post-7218134)
 * Unfortunately after some traffic and several attempts
    the problem occurs again;-(
 * > `
   >  Warning: stream_socket_client(): unable to connect to tcp://mobileuiux.pl:
   > 80 (Connection refused) in /var/www/html/wordpress/wp-includes/class-wp-http-
   > streams.php on line 150 `
 * Please look at this again ([mobileuiux.pl
    
   ) and help me with this issue.
 * Thanks in advance !
 *  Thread Starter [aiopa](https://wordpress.org/support/users/aiopa/)
 * (@aiopa)
 * [10 years ago](https://wordpress.org/support/topic/stream_socket_client/#post-7218135)
 * Your issue is not with this pluggin 😛

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘stream_socket_client()’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-pdf-templates_ffffff.svg)
 * [WordPress PDF Templates](https://wordpress.org/plugins/wp-pdf-templates/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-pdf-templates/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-pdf-templates/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-pdf-templates/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-pdf-templates/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-pdf-templates/reviews/)

 * 9 replies
 * 3 participants
 * Last reply from: [aiopa](https://wordpress.org/support/users/aiopa/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/stream_socket_client/#post-7218135)
 * Status: resolved