1

I've build a little website where users are able to send notifications to other users through pushover (https://www.pushover.net).

Everything is working fine except the limitation besides pushover (https://pushover.net/api#limits):

"Do not send more than 2 concurrent HTTP requests (TCP connections) to our API..... To speed up multiple requests, you may send each request in sequence over the same TCP connection using HTTP keep-alive to avoid the overhead of a new TCP connection and SSL negotiation. Do not retry the same request more than once every 5 seconds. ....".

So as I understand I have to send less than 2 Messages in 5 Seconds right? But in my case I have round about 4-5 messages/second sometimes. has anyone an idea how to do this "HTTP keep-alive"-thing to keep it going?

For sending I actually use "php-pushover" from Chris Schalenborgh.

My method looks like this:

function alertSend($title, $message, $participants, $account){
    $timestamp = time();
    $datum = date("d.m.Y - H:i", $timestamp);
    $pushover = new Pushover();
    $pushover->setToken($account->alerts);
    $pushover->setUser($account->usertoken);
    $devices = validateUser($account->alerts, $account->usertoken, $account->verify);
    foreach($participants as $user){
        if (strpos($devices, $user) !== false) {
            $final .= $user.",";
        }
    }
    if(!empty($final)){
        $pushover->setDevice($final);
        $pushover->setPriority('1');
        $pushover->setExpire('300');
        $pushover->setRetry('30');
        $pushover->setTitle($title);
        $pushover->setMessage($message);

        if(isset($final)){
            $final = '';
        }
    }
}

In my opinion there is no failure generally.

I hope that anyone has an answer how to solve this.

Inigo Flores
  • 4,461
  • 1
  • 15
  • 36
  • I don't see anything that says no more than 2 messages in 5 seconds. You aren't supposed to *retry* a message before 5 seconds, but the "2" limit is related to **concurrent** messages -- meaning, sent at the same time, in parallel. What actual problem are you encountering? – Michael - sqlbot Dec 13 '15 at 00:25
  • The problem is that if im sending iE 5 messages in a minute no error happend but when there are 1 message per second (10 mesages send) only 4-5 messages arrived to the users. (Sorry fpr my incredible bad english ;)) – Florian Rahmann Dec 13 '15 at 12:53
  • What you describe is not the problem, it's the result of the problem. Don't send more than 2 messages per second! You will need to mark the time the last message was sent and wait until at least until 500ms have passed to send a new one. That's the easiest solution, or else you will need to dig into the curl options to see if it is even possible to `keep-alive` a request and reuse it from PHP/curl. – user221931 Dec 14 '15 at 10:44

0 Answers0