spatie / laravel-webhook-client

Receive webhooks in Laravel apps
https://freek.dev/1383-sending-and-receiving-webhooks-in-laravel-apps
MIT License
985 stars 146 forks source link

QueryException #183

Closed vista-narvas closed 1 year ago

vista-narvas commented 1 year ago

whenever i send a webhook to the client i get the following error

SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: insert into `webhook_calls` (`name`, `url`, `headers`, `payload`, `updated_at`, `created_at`) values (default, http://homepage.site.tech/webhook, [], [], 2023-03-13 18:39:48, 2023-03-13 18:39:48))

the connection says Connection refused even touh the DB is working fine as far as i can tell

if i run a insert or select using tinker it works

> DB::insert('insert into webhook_calls'.PHP_EOL.' (name, url, headers, payload, updated_at, created_at) values (?,?,?,?,?,?)', ['default', 'https://test.com/webhook', null, null, '2023-03-13 16:56:32', '2023-03-13 16:56:32']);
= true

> DB::select('select * from webhook_calls');= [
    {#3750
      +"id": 1,
      +"name": "default",
      +"url": "https://test.com/webhook",
      +"headers": null,
      +"payload": null,
      +"exception": null,
      +"created_at": "2023-03-13 16:56:32",
      +"updated_at": "2023-03-13 16:56:32",
    },
    {#3747
      +"id": 2,
      +"name": "default",
      +"url": "https://test.com/webhook",
      +"headers": null,
      +"payload": null,
      +"exception": null,
      +"created_at": "2023-03-13 16:56:32",
      +"updated_at": "2023-03-13 16:56:32",
    },
  ]

this is a fresh install of laravel PHP: 8.2.3 Laravel: 10.3.3

vista-narvas commented 1 year ago

steps i took to reproduce

  1. composer create-project laravel/laravel .
  2. composer require spatie/laravel-webhook-client
  3. php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-config"
  4. php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-migrations"
  5. php artisan migrate:fresh
  6. vi routes/web.php add Route::webhooks('webhook');
  7. vi app/Http/Middleware/VerifyCsrfToken.php add webhook to $except
  8. vi app/Http/Webhook/GiteaValidator.php custom validator that always give true
    
    <?php
    namespace App\Http\Webhook;

use Illuminate\Http\Request; use Spatie\WebhookClient\SignatureValidator\SignatureValidator; use Spatie\WebhookClient\WebhookConfig;

class GiteaValidator implements SignatureValidator { public function isValid(Request $request, WebhookConfig $config): bool { return true; } }

9. `vi app/Jobs/Webhook.php` as minimal class that never gets reached

<?php

namespace App\Jobs;

use Spatie\WebhookClient\Jobs\ProcessWebhookJob;

class Webhook extends ProcessWebhookJob { public function __construct() { logger("yay construct"); }

public function handle(): void
{
    logger("yay handle");
}

}


10. `vi config/webhook-client.php` set `'signature_validator' => App\Http\Webhook\GiteaValidator::class` and `'process_webhook_job' => App\Jobs\Webhook::class`
11. `php artisan serve`
12. send a webhook and recive a error
vista-narvas commented 1 year ago

i did some more tests i tried the same install commands in a Ubuntu container and than everything works fine so i think im missing a php package but i dont know which package