卷曲超时卷曲并发送推送通知

卷曲超时卷曲并发送推送通知

问题描述:

I have some problems with push notification with php & android.

When I make new order with android app after it insert to database and before response to android app, I start a service whit bellow code:

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, "token=" . config('app.passwords.service_token'));
    curl_setopt($curl, CURLOPT_TIMEOUT, 1);
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 1);
    curl_setopt($curl, CURLOPT_NOSIGNAL, 1);
    curl_setopt($curl, CURLOPT_HEADER, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
    $response = curl_exec($curl);
    curl_close($curl);

This code will send the push notification.

I have problem with curl timeout. In this code it is 1 second. In most cases, the request sent with curl takes more time and is not sent push as a result. If we increase the timeout value, the answer will be delayed to the android app and problems will be on the Android side.

What do you suggest? What should I do?

我在使用php& amp的推送通知方面遇到了一些问题 安卓。 p>

当我插入数据库并在响应Android应用程序之前使用Android应用程序进行新订单时,我启动了一个服务版本,如下所示: p> $ curl = curl_init(); curl_setopt($ curl,CURLOPT_URL,$ url); curl_setopt($ curl,CURLOPT_POST,1); curl_setopt($ curl,CURLOPT_POSTFIELDS,“token =” .config('app.passwords.service_token')); curl_setopt($ curl,CURLOPT_TIMEOUT,1); curl_setopt($ curl,CURLOPT_CONNECTTIMEOUT,1); curl_setopt($ curl,CURLOPT_NOSIGNAL,1); \ n curl_setopt($ curl,CURLOPT_HEADER,0); curl_setopt($ curl,CURLOPT_RETURNTRANSFER,true); curl_setopt($ curl,CURLOPT_FRESH_CONNECT,true); $ response = curl_exec($ curl); curl_close( $ curl); code> pre>

此代码将发送推送通知。 p>

我有卷曲超时问题。 在这段代码中它是1秒。 在大多数情况下,使用curl发送的请求需要更多时间,因此不会发送推送。 如果我们增加超时值,答案将延迟到Android应用程序,问题将 在Android方面。 p>

你有什么建议? 我该怎么办? p> div>

I would suggest you increase the:

CURLOPT_TIMEOUT > CURLOPT_CONNECTTIMEOUT

because if your server's bandwidth usage is high or you are not on production server and your connection speed is very low, it might take a few seconds to connect and when the connection is successful then it will try to send the push, so yes