title: Cometd Java Client won't publish to Cometd server
body: <p>I followed the examples that I could find for making a Cometd java client application.  I am trying to make it so when the user presses a button on the screen, cometd publishes a message to the server.  Right now the publish gets called but the server never receives message to its listener.  I have this server listener working with javascript but not java code.</p>
  
  <p>Client side setup is as follows:</p>
  
  <pre><code>        // Prepare the transport
          Map&lt;String, Object&gt; options = new HashMap&lt;String, Object&gt;();
          ClientTransport transport = LongPollingTransport.create(options, httpClient);
  
          _client = new BayeuxClient("http://10.100.97.168:8888/slideshow/slideshow/", transport);
          _client.getChannel(Channel.META_HANDSHAKE).addListener(new InitializerListener());
          _client.getChannel(Channel.META_CONNECT).addListener(new ConnectionListener());
  </code></pre>
  
  <p>My handshake and connection listeners:</p>
  
  <pre><code>private class InitializerListener implements ClientSessionChannel.MessageListener
      {
          public void onMessage(ClientSessionChannel channel, Message message)
          {
              if (message.isSuccessful())
              {
                  _handshaked = true;
              }
              else
              {
                  _handshaked = false;
              }
          }
      }
  
      private class ConnectionListener implements ClientSessionChannel.MessageListener
      {
          private boolean wasConnected;
          private boolean connected;
  
          public void onMessage(ClientSessionChannel channel, Message message)
          {
              if (_client.isDisconnected())
              {
                  connected = false;
                  connectionClosed();
                  return;
              }
  
              wasConnected = connected;
              connected = message.isSuccessful();
              if (!wasConnected &amp;&amp; connected)
              {
                  connectionEstablished();
              }
              else if (wasConnected &amp;&amp; !connected)
              {
                  connectionBroken();
              }
          }
      }
  </code></pre>
  
  <p>Button press that tries to publish:</p>
  
  <pre><code>_btnPlay.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
                  if(_connection_established == true)
                  {
                      Map&lt;String, Object&gt; data = new HashMap&lt;String, Object&gt;();
                      _clientSessionChannel.publish(data);
                  }
              }
           });
  </code></pre>
  
  <p>Just in case here is my server Listener too:</p>
  
  <pre><code>@Listener("/service/slide/play")
      public void processServiceSlidePlay(ServerSession client, ServerMessage message)
      {
          synchronized(imagelock)
          {
              if(slideShowRunning == false &amp;&amp; imageIDList != null &amp;&amp; imageIDList.size() &gt; 0)
              {
                  slideShowRunning = true;
                  if(imageIDList != null &amp;&amp; imageIDList.size() &gt; 0)
                  {           
                      deliverChangeMessage(client, message);  
                  }
              }
          }
      }
  </code></pre>
  
  <p>So I can establish a connection and my publish gets called, but the server never picks it up.  Also I noticed if I do the same exact publish but in my handshake or connect callback, the server will pick it up.  Seems like I just can't do a publish outside of the callbacks.</p>
  
  <p>Thanks in Advance for the Help.</p>