WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#27091 closed defect (bug) (duplicate)

Timeout to WordPress API in update.php

Reported by: dsevillano Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8.1
Component: Cron API Keywords:
Focuses: administration Cc:
PR Number:

Description

Hi,

I was updating the plugins of my WordPress and I was getting all the time this error:

An unexpected error occurred. Something may be wrong with WordPress.org or this server's configuration.

'''WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.'''

/wp-includes/update.php on line 267

I went more deep and I have just found the problem is coming form the timeout to the call of WordPress API:

http://api.wordpress.org/plugins/update-check/1.1/

The timeout is hardcode, It is defined as 3 seconds and I can not override that configuration without modified the core of WordPress (something I don't want to do).

/wp-includes/update.php on line 252

		'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3)

If you follow the request across the code of Wordpress, It is going to the file:

/wp-includes/class-http.php on line 67

In the function request you can see the defaults params for the request and the apply_filters but that configuration will be override from the hardcode I have already talk before.

	'timeout' => apply_filters( 'http_request_timeout', 5),

Change History (4)

#1 @SergeyBiryukov
6 years ago

  • Summary changed from Timeout to Wordpress API in update.php to Timeout to WordPress API in update.php

I get this too from time to time.

#2 @ocean90
6 years ago

Related/Duplicate: #25788

#3 in reply to: ↑ description @SergeyBiryukov
6 years ago

In the function request you can see the defaults params for the request and the apply_filters but that configuration will be override from the hardcode I have already talk before.

You can increase the timeout using http_request_args filter:

function increase_timeout_for_api_requests_27091( $r, $url ) {
	if ( false !== strpos( $url, '//api.wordpress.org/' ) ) {
		$r['timeout'] = 30;
	}

	return $r;
}
add_filter( 'http_request_args', 'increase_timeout_for_api_requests_27091', 10, 2 );

#4 @SergeyBiryukov
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Originally introduced in [5913], changed in [8630] and [11826].

Closing as a duplicate of #25788.

Note: See TracTickets for help on using tickets.