title: Websocket paused when android app goes to background
body: <p>My android app starts a service that opens a websocket to communicate to a remote server.  The service spawns a thread whose run method looks like this.</p>
  
  <pre><code>public void run() {
          try {
              super.run();
  
              for(int i = 1; i &lt; 1000; i++) {
                  Log.d(TAG, String.format(" *** Iteration #%d.", i));
                  Thread.sleep(3000); // Dummy load.
                  mWebsocket.sendTextMessage("Test");
              }
          }
          catch (Exception exc) {
              Log.d(MY_TAG, "MyThread.run - Exception: " + exc.getMessage());
          }
      }
  </code></pre>
  
  <p>When I turn off the screen or send the app to the background, logcat shows that the loop is running, but the remote server stops receiving the test messages.  Apparently, the messages are pooling somewhere because once the app is back to the foreground, the server will received a bunch of test messages.  Is this the expected behavior on Android?  I've tried different Websocket packages (Autobahn, okhttp3, ...) and the result is the same.     </p>