Hello. With DRUPAL 10.6.2 in php 8.4
I tried to synchronize my users from Drupal with users in DOLIBARR.

I encountered this error:

Dispatch Failed. Subscriber dolibarr_sync on Webhook b10f758c-83f4-4af3-b6ee-318d0f81a5e7 for Event entity:user:update: cURL error 28: Operation timed out after 100 milliseconds with 77 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://erp.exemple.fr/api/index.php/users?

I tried to edit my .settings.php

$settings['http_client']['timeout'] = 45;
ini_set('default_socket_timeout', 60);
ini_set('max_execution_time', 120);

But no result.

Do you have a solution ?

PS: If i test with hook_user_insert(), hook_user_update(), hook_user_delete()
with a function, the user is created in DOLIBARR like expected.

The second problem is the token.

If i put the token in the url it's ok - like this:
https://erp.exemple.fr/api/index.php/users?DOLAPIKEY=9999999999999999
If not the token expected is THE_DOLAPIKEY not DOLAPIKEY and the acess is refused.

Issue fork webhooks-3567271

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bkaernel created an issue. See original summary.

bkaernel’s picture

Issue summary: View changes
bkaernel’s picture

Issue summary: View changes
bkaernel’s picture

Issue summary: View changes
bluegeek9’s picture

Assigned: bkaernel » bluegeek9

This is not caused by PHP’s default_socket_timeout or Drupal’s global HTTP client timeout. The Webhooks module sets its own timeout here:

WebhooksService.php Lines 191-200

$this->client->post(
  $webhook_config->getPayloadUrl(),
  [
    'headers' => $webhook->getHeaders(),
    'body' => $body,
    // Workaround for blocking local to local requests,
    // there will be 'Dispatch Failed' errors in the logs.
    'timeout' => (strpos($webhook_config->getPayloadUrl(), $this->requestStack->getCurrentRequest()->getHost())) ? 0.1 : 0,
  ]
);

So if your Drupal host is exemple.fr, and the Dolibarr URL is https://erp.exemple.fr/..., the string exemple.fr appears inside the Dolibarr URL. The module treats it as a “local to local” request and forces a 0.1 second timeout.

Recommended fix in the module code would be to compare hosts instead of using strpos():

$current_host = $this->requestStack->getCurrentRequest()->getHost();
$payload_host = parse_url($webhook_config->getPayloadUrl(), PHP_URL_HOST);
'timeout' => $payload_host === $current_host ? 0.1 : 45,

bluegeek9’s picture

Assigned: bluegeek9 » Unassigned
Status: Active » Needs review