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

Curl error on Laravel 11 #219

Closed
kaustuv90 opened this issue May 5, 2024 · 9 comments
Closed

Curl error on Laravel 11 #219

kaustuv90 opened this issue May 5, 2024 · 9 comments
Assignees

Comments

@kaustuv90
Copy link

Describe the bug

when sending notifications locally it works but when uploaded to the live server it gives a 411 error.
here is the error description
`cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://fcm.googleapis.com/v1/projects/pixify-de9ec/messages:send
Kreait
 \ 
Firebase
 \ 
Exception
 \ 
Messaging
 \ 
MessagingError
PHP 8.3.3
11.6.0
cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://fcm.googleapis.com/v1/projects/pixify-de9ec/messages:send

Expand vendor frames
20 vendor frames
Illuminate
 \ 
Routing
 \ 
RouteFileRegistrar

: 39
{closure}
46 vendor frames
routes
 / 
web
.php

: 39

// 'auth:sanctum',

// config('jetstream.auth_session'),

// 'verified',

//])->group(function () {

// Route::get('/dashboard', function () {

// return view('dashboard');

// })->name('dashboard');

//});

Route::get('/privacy_policy', function () {

return view('pages.privacy_policy');

})->name('privacy_policy');

Route::get('/notify', function () {

// $cloudMessaging = Firebase::messaging();

// $message = CloudMessage::withTarget('topic', 'general')

//     ->withNotification(Notification::create("Test Notification", 'Success'));

// $status = $cloudMessaging->send($message);

// dd($status);





$messaging = app('firebase.messaging');

$message = CloudMessage::withTarget('topic', 'general')

->withNotification(Notification::create('Title', 'Body'))

->withData(['key' => 'value']);



dd($messaging->send($message));

});`

Installed packages

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The skeleton application for the Laravel framework.",
    "keywords": ["laravel", "framework"],
    "license": "MIT",
    "require": {
        "php": "^8.2",
        "filament/filament": "3.2.72",
        "intervention/image": "^3.6",
        "kreait/firebase-php": "^7.10",
        "kreait/laravel-firebase": "^5.8",
        "laravel/framework": "^11.0",
        "laravel/jetstream": "^5.0",
        "laravel/sanctum": "^4.0",
        "laravel/telescope": "^5.0",
        "laravel/tinker": "^2.9",
        "league/color-extractor": "^0.4.0",
        "livewire/livewire": "^3.0"
    },
    "require-dev": {
        "fakerphp/faker": "^1.23",
        "laravel/pint": "^1.13",
        "laravel/sail": "^1.26",
        "mockery/mockery": "^1.6",
        "nunomaduro/collision": "^8.0",
        "phpunit/phpunit": "^11.0.1",
        "spatie/laravel-ignition": "^2.4"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi",
            "@php artisan filament:upgrade"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi",
            "@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
            "@php artisan migrate --graceful --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "allow-plugins": {
            "pestphp/pest-plugin": true,
            "php-http/discovery": true
        }
    },
    "minimum-stability": "stable",
    "prefer-stable": true
}

PHP version and extensions

composer               2.6.6     Composer package
composer-plugin-api    2.6.0     The Composer Plugin API
composer-runtime-api   2.2.2     The Composer Runtime API
ext-bcmath             8.3.3     The bcmath PHP extension
ext-ctype              8.3.3     The ctype PHP extension
ext-curl               8.3.3     The curl PHP extension
ext-date               8.3.3     The date PHP extension
ext-dom                20031129  The dom PHP extension
ext-fileinfo           8.3.3     The fileinfo PHP extension
ext-filter             8.3.3     The filter PHP extension
ext-ftp                8.3.3     The ftp PHP extension
ext-gd                 8.3.3     The gd PHP extension
ext-gettext            8.3.3     The gettext PHP extension
ext-hash               8.3.3     The hash PHP extension
ext-iconv              8.3.3     The iconv PHP extension
ext-intl               8.3.3     The intl PHP extension
ext-json               8.3.3     The json PHP extension
ext-libxml             8.3.3     The libxml PHP extension
ext-mbstring           8.3.3     The mbstring PHP extension
ext-mysqli             8.3.3     The mysqli PHP extension
ext-mysqlnd            0         The mysqlnd PHP extension (actual version: mysqlnd 8.3.3)
ext-openssl            8.3.3     The openssl PHP extension
ext-pcntl              8.3.3     The pcntl PHP extension
ext-pcre               8.3.3     The pcre PHP extension
ext-pdo                8.3.3     The PDO PHP extension
ext-pdo_mysql          8.3.3     The pdo_mysql PHP extension
ext-pdo_sqlite         8.3.3     The pdo_sqlite PHP extension
ext-phar               8.3.3     The Phar PHP extension
ext-posix              8.3.3     The posix PHP extension
ext-random             8.3.3     The random PHP extension
ext-reflection         8.3.3     The Reflection PHP extension
ext-session            8.3.3     The session PHP extension
ext-shmop              8.3.3     The shmop PHP extension
ext-simplexml          8.3.3     The SimpleXML PHP extension
ext-soap               8.3.3     The soap PHP extension
ext-sockets            8.3.3     The sockets PHP extension
ext-sodium             8.3.3     The sodium PHP extension
ext-spl                8.3.3     The SPL PHP extension
ext-sqlite3            8.3.3     The sqlite3 PHP extension
ext-sysvsem            8.3.3     The sysvsem PHP extension
ext-tokenizer          8.3.3     The tokenizer PHP extension
ext-xml                8.3.3     The xml PHP extension
ext-xmlreader          8.3.3     The xmlreader PHP extension
ext-xmlwriter          8.3.3     The xmlwriter PHP extension
ext-zip                1.22.3    The zip PHP extension
ext-zlib               8.3.3     The zlib PHP extension
lib-curl               7.70.0    The curl library
lib-curl-openssl       1.0.2.21  curl OpenSSL version (1.0.2.21)
lib-curl-zlib          1.2.7     curl zlib version
lib-date-timelib       2022.10   date timelib version
lib-date-zoneinfo      2023.4    zoneinfo ("Olson") database for date
lib-fileinfo-libmagic  543       fileinfo libmagic version
lib-gd                 2.0.35    The gd library
lib-gd-freetype        2.8.0     freetype version for gd
lib-gd-libjpeg         6.2       libjpeg version for gd
lib-gd-libpng          1.5.13    libpng version for gd
lib-iconv              2.17      The iconv library
lib-icu                50.2      The ICU unicode and globalization support library
lib-icu-cldr           2.0.78.30 ICU CLDR project version
lib-icu-unicode        6.2.0     ICU unicode version
lib-icu-zoneinfo       2018.5    zoneinfo ("Olson") database for icu
lib-libsodium          1.0.18    The libsodium library
lib-libxml             2.9.1     libxml library version
lib-mbstring-libmbfl   1.3.2     mbstring libmbfl version
lib-mbstring-oniguruma 6.8.2     mbstring oniguruma version
lib-openssl            1.0.2.21  OpenSSL 1.0.2u  20 Dec 2019
lib-pcre               10.42     The pcre library
lib-pcre-unicode       14.0.0    PCRE Unicode version support
lib-pdo_sqlite-sqlite  3.7.17    The pdo_sqlite-sqlite library
lib-sqlite3-sqlite     3.7.17    The sqlite3-sqlite library
lib-zip-libzip         1.5.2     The zip-libzip library
lib-zlib               1.2.7     The zlib library
php                    8.3.3     The PHP interpreter
php-64bit              8.3.3     The PHP interpreter, 64bit
php-ipv6               8.3.3     The PHP interpreter, with IPv6 support

Steps to reproduce the issue.

# Insert the commands issued in the terminal if they are needed
# to reproduce the issue. Otherwise, delete this code block.
// Insert the PHP code to reproduce the issue. Please ensure that it is code that
// can be copy pasted to reproduce it.

Error message/Stack trace

cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent

Additional information

No response

@jeromegamez
Copy link
Member

If something works locally but not on a remote machine, it's usually something in the remote environment that doesn't work. I'm not familiar with this particular error, but it looks like a networking problem, perhaps there's a misbehaving proxy somewhere or another problem with the internet/network connection.

I can not do more than take guesses, but I'm quite sure this is not something I can fix in code, so I'll have to close this issue.

Please keep in mind that I don't work for Google, so I can't say anything about Firebase, the service. If you believe your environment has no problems, you might want to create a support issue with them.

Good luck!

@jeromegamez jeromegamez closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2024
@kaustuv90
Copy link
Author

kaustuv90 commented May 6, 2024

Sorry but everything is correct on my side let me clear.
there is 2 different laravel project I created both are ^11.0 but on one its working but with another its not working if you want i can post both composer.json file. same server same firebase but one working another not. maybe laravel did something worn in new update.

those 2 projects are on both laravel 11 but one is old release and one is new. the new one does not work. as soon as I upgraded the old to new its stopped working.

you can try yourself installing the latest laravel.
something wrong with guzzle it seems

@kaustuv90
Copy link
Author

So now i figured out the issue
when using kreait/firebase-php:v7.9.1 it works fine but as soon as I upgrade to version v7.10.0 then I get the guzzle HTTP error

@jeromegamez
Copy link
Member

jeromegamez commented May 6, 2024

Thank you for providing this detail!

7.10 switched from using consequent HTTP/1.1 request to concurrent HTTP/2 requests. This by itself shouldn't be a problem, but the memory usage can increase, depending on how many requests are sent, due to changes on how these requests are handled by the SDK. How many messages are you sending?

It should be possible to reduce the memory footprint by sending the messages in batches instead of all at once.

@kaustuv90
Copy link
Author

Yeah I found the issue that when use old version of nginx it doesn't support http2 and it doesn't send proper request body to Google api so when update the nginx version everything solved.
Thanks for your great support.

@jeromegamez
Copy link
Member

Thank you for sharing your findings, I'm sure this will be very helpful to others stumbling upon this issue!

@bilulanlv
Copy link

Yeah I found the issue that when use old version of nginx it doesn't support http2 and it doesn't send proper request body to Google api so when update the nginx version everything solved. Thanks for your great support.

What is the nginx version number you are using?

@Smallplanegithub
Copy link

是的,我发现问题是,使用旧版本的 nginx 时,它不支持 http2,并且不会向 Google api 发送正确的请求主体,因此,当更新 nginx 版本时,所有问题都解决了。 感谢您的大力支持。
Boss, which version of Nginx are you ultimately using?

@jeromegamez
Copy link
Member

jeromegamez commented May 30, 2024

Could you please test with kreait/firebase-php#903 if this solves the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants