Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout on ajax_verify_external_connection #244

Closed
madmax3365 opened this issue Oct 26, 2018 · 2 comments
Closed

Timeout on ajax_verify_external_connection #244

madmax3365 opened this issue Oct 26, 2018 · 2 comments
Labels
type:bug Something isn't working.
Milestone

Comments

@madmax3365
Copy link
Contributor

When trying to create an external connection with the site, which has over 10 post types ajax_verify_external_connection can't establish a connection because of a timeout.
The core problem in WordPressExternalConnection's check_connections method. It gets all post types available in REST and does for each of them remote_get and remote_post to check user's permissions.


foreach ( $types as $type_key => $type ) {
...
$type_response = wp_remote_get( $link, $this->auth_handler->format_get_args( array( 'timeout' => self::$timeout ) ) );
}
if ( ! is_wp_error( $type_response ) ) {
$code = (int) wp_remote_retrieve_response_code( $type_response );
if ( 401 !== $code ) {
$can_get[] = $type_key;
}
...
if ( in_array( 'POST', $routes[ $route ]['methods'], true ) ) {
$type_response = wp_remote_post(
$link,
$this->auth_handler->format_post_args(
array(
'timeout' => self::$timeout,
'body' => array( 'test' => 1 ),
)
)
);
if ( ! is_wp_error( $type_response ) ) {
$code = (int) wp_remote_retrieve_response_code( $type_response );
if ( 401 !== $code ) {
$can_post[] = $type_key;
}
}
}
...
}

@arsendovlatyan
Copy link
Contributor

Hey @helen ,
In our case we have ~15 post types and it's a problem to get external connection verified, usually, therefore, we had to change external connection verification process.
It will be very nice if we can include this change in next releases, for sure happy to make any improvement/fix that you will point out.

@helen
Copy link
Contributor

helen commented Oct 30, 2018

Thanks for the diagnosis and PR - we will take a look at your approach and consider it as we figure out our ideal scenario for how this should work.

@helen helen added this to the 1.4 milestone Nov 13, 2018
@jeffpaul jeffpaul added the type:bug Something isn't working. label Jun 24, 2019
@jeffpaul jeffpaul modified the milestones: 3.0.0, 1.6.0 Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

4 participants