title: Did not get any data from server using socket programming in phone gap
body: <p>I am implementing socket programming in android using  phonegap. But i am not getting any data from server.Actually  my PC is am consumer as  producer .So i am hitting only to my ip address but i am not getting any error .But did not get any response .
  Please help me . ...</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
      &lt;title&gt;websocket-android-phonegap&lt;/title&gt;
      &lt;script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" charset="utf-8" src="js/websocket.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
  
  
    &lt;/body&gt;
  
  &lt;script type="text/javascript" charset="utf-8"&gt;
      // new socket
      alert("Start");
      //var socket = new WebSocket('ws://192.168.12.171:8101/');
      var socket = new WebSocket('http://192.168.12.171:8001');
  
      // push a message after the connection is established.
      socket.onopen = function() {
      alert("Open")
          //socket.send('Hello World')
      };
  
      // alerts message pushed from server
      socket.onmessage = function(msg) {
          alert(JSON.stringify(msg));
      };
  
      // alert close event
      socket.onclose = function() {
          alert('closed');
      };
  
      // now, close the connection after 10 secons. (funny!)
      /*setInterval(function() {
          socket.close();
      }, 10000); */
  &lt;/script&gt;  
  
  &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>(function() {
  
      // window object
      var global = window;
  
      // WebSocket Object. All listener methods are cleaned up!
      var WebSocket = global.WebSocket = function(url) {
      alert("---")
          // get a new websocket object from factory (check com.strumsoft.websocket.WebSocketFactory.java)
          this.socket = WebSocketFactory.getInstance(url);
          // store in registry
          if(this.socket) {
              WebSocket.store[this.socket.getId()] = this;
          } else {
              throw new Error('Websocket instantiation failed! Address might be wrong.');
          }
      };
  
      // storage to hold websocket object for later invokation of event methods
      WebSocket.store = {};
  
      // static event methods to call event methods on target websocket objects
      WebSocket.onmessage = function (evt) {
          WebSocket.store[evt._target]['onmessage'].call(global, evt);
      }   
  
      WebSocket.onopen = function (evt) {
          WebSocket.store[evt._target]['onopen'].call(global, evt);
      }
  
      WebSocket.onclose = function (evt) {
          WebSocket.store[evt._target]['onclose'].call(global, evt);
      }
  
      WebSocket.onerror = function (evt) {
          WebSocket.store[evt._target]['onerror'].call(global, evt);
      }
  
      // instance event methods
      WebSocket.prototype.send = function(data) {
          this.socket.send(data);
      }
  
      WebSocket.prototype.close = function() {
          this.socket.close();
      }
  
      WebSocket.prototype.getReadyState = function() {
          this.socket.getReadyState();
      }
      ///////////// Must be overloaded
      WebSocket.prototype.onopen = function(){
          throw new Error('onopen not implemented.');
      };
  
      // alerts message pushed from server
      WebSocket.prototype.onmessage = function(msg){
          throw new Error('onmessage not implemented.');
      };
  
      // alerts message pushed from server
      WebSocket.prototype.onerror = function(msg){
          throw new Error('onerror not implemented.');
      };
  
      // alert close event
      WebSocket.prototype.onclose = function(){
          throw new Error('onclose not implemented.');
      };
  })();
  </code></pre>