$subscription = Subscription::create(json_decode($endpoint, true));
$auth = [
"VAPID" => [
"subject" => "mailto:me@website.com", // can be a mailto: or your website address
"publicKey" => $publicKey, // (recommended) uncompressed public key P-256 encoded in Base64-URL
"privateKey" => $privateKey, // (recommended) in fact the secret multiplier of the private key encoded in Base64-URL
//"pemFile" => "private_key.pem", // if you have a PEM file and can link to it on your filesystem
],
];
$temp = new StdClass();
$temp->title = "Notifica da PHP";
$temp->body = "Questo testo arriva dal server";
$temp->url = "/";
Sending the notification takes 12 seconds on the old windows server, 6 seconds on the new windows server and 0.5 on linux. Is this expected/normal? Is there anything I can do to improve this/am I doing something wrong?
Setup
Problem
This is my code:
`<?php require_once("vendor/autoload.php"); use Minishlink\WebPush\Subscription; use Minishlink\WebPush\WebPush;
$endpoint = ""; $publicKey = ""; $privateKey = "";
$subscription = Subscription::create(json_decode($endpoint, true)); $auth = [ "VAPID" => [ "subject" => "mailto:me@website.com", // can be a mailto: or your website address "publicKey" => $publicKey, // (recommended) uncompressed public key P-256 encoded in Base64-URL "privateKey" => $privateKey, // (recommended) in fact the secret multiplier of the private key encoded in Base64-URL //"pemFile" => "private_key.pem", // if you have a PEM file and can link to it on your filesystem ], ]; $temp = new StdClass(); $temp->title = "Notifica da PHP"; $temp->body = "Questo testo arriva dal server"; $temp->url = "/";
$payload = json_encode($temp); $webPush = new WebPush($auth); $start_time = microtime(true); $report = $webPush->sendOneNotification($subscription, $payload, ["TTL" => 5000]); $end_time = microtime(true); $elapsed_time = $end_time - $start_time; echo "Tempo trascorso: " . number_format($elapsed_time, 4) . " secondi"; print_r($report->isSuccess() ? "SUCCESS" : "FAILED"); print_r($report->getReason());`
Sending the notification takes 12 seconds on the old windows server, 6 seconds on the new windows server and 0.5 on linux. Is this expected/normal? Is there anything I can do to improve this/am I doing something wrong?
Expected
A gap less big.
Features Used
Example / Reproduce Case
Aformentioned.
Other