Interesting. did you try to profile your PHP page to see where the bottleneck might be, e.g. do you finish sending the requests quickly and then wait 10 minutes while google sends the c2dm messages or each curl request takes a couple of seconds and it ads up.
I'm asking because it can lead to a different type of solution, for example running curl requests concurrently in case it's the second scenario. Efi On Nov 8, 5:04 pm, kouz <[email protected]> wrote: > hi, > > I try to create a php server to send message with c2dn. > The process is very slow, It take more than 10 min to send 5000 > messages. > > the code is very simple: > First I connect to google: > $this->ch = curl_init(); > $post_fields = "accountType=" . urlencode('GOOGLE') . > "&Email=" . urlencode($username) . "&Passwd=" . urlencode($password) . > "&source=" . urlencode($source) . "&service=" . urlencode($service); > > curl_setopt($this->ch, CURLOPT_URL, "https://www.google.com/ > accounts/ClientLogin"); > curl_setopt($this->ch, CURLOPT_HEADER, true); > curl_setopt($this->ch, CURLOPT_POST, true); > curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post_fields); > curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); > curl_setopt($this->ch, CURLOPT_FRESH_CONNECT, true); > > curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); > curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false); > curl_setopt($this->ch, CURLOPT_TIMEOUT, 10); > curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 10); > > $response = curl_exec($this->ch); > > After login, I send the message to each users with the same > connection : > > while($deviceToken){ > $post_fields = "xxxxxx&collapse_key=aaaa" . > "&data.message=" . urlencode($message); > curl_setopt($this->ch, CURLOPT_URL, "http:// > android.apis.google.com/c2dm/send"); > curl_setopt($this->ch, CURLOPT_HTTPHEADER, $headers); > curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false); > curl_setopt($this->ch, CURLOPT_POST, true); > curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); > curl_setopt($this->ch, CURLOPT_POSTFIELDS, > "registration_id=" . $deviceToken.$post_fields); > $result=curl_exec($this->ch); > > } > > Somebody know a better (faster) way to do the job? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

