title: Connecting to GCM server running at local server
body: <p>I am working on push notifications with Google Cloud Messaging(GCM). I am able to setup server and client side following <a href="http://androidv5.wordpress.com/2012/08/15/how-to-implement-google-cloud-messaging/" rel="nofollow">this tutorial</a>. </p>
  
  <p>The server runs on Apache Tomcat6.0 (localhost) and Android emulator on Google APIs (API level 17). I have a sender id and API key. When run from the emulator, I get a successful device connection message. Sooner after that, upon sending message from server shows the following error.</p>
  
  <pre><code>com.google.android.gcm.server.InvalidRequestException: HTTP Status Code: 401()
  com.google.android.gcm.server.Sender.sendNoRetry(Sender.java:211)
  com.google.android.gcm.server.Sender.send(Sender.java:125)
  com.google.android.gcm.demo.server.SendAllMessagesServlet.doPost(SendAllMessagesServlet.java:83)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  </code></pre>
  
  <p>From other posts, I understand wrong API key is the culprit. But in my case, I made sure I am using the right one from the API console. </p>
  
  <p>By the way, when I run the emulator, I saw a message 'sending regId to server'. What is the registration id? It is not same as sender id; looks like an encoded one.</p>
  
  <p>Any break through?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The issue is finally solved! Ant was not properly building the WAR file. So API key hardly gets updated. It was hell of a nightmare to spot the bug. Thanks all for the inputs!</p>