title: android.os.BinderProxy cannot be cast to org.eclipse.paho.android.service.MqttServiceBinder
body: <p>I'm working on an app that includes a chat feature using the MqttAndroidClient and I have been having an issue initializing the client.</p>
  
  <p>What I'm trying to achieve is to run a seperate process(using <em>:remote</em>) to run the mqtt client to subscribe to the broker in order to fetch the messages from my chat server.
  The remote service is created within the Main Activity and I've set the IPC using an AIDL.
  I know that the error code points out that there is an error with the IPC; however, I can't seem to find the reason why, because I'm pretty sure I've set the AIDL correctly.</p>
  
  <p>Long story short, here is my service codes:</p>
  
  <pre><code>private static final String MQTT_BROKER = "________(blank on purpose)";
  private String userId;
  private String publishTopic;
  private String subscribeTopic;
  MqttAndroidClient client;
  
  @Nullable
  @Override
  public IBinder onBind(Intent intent) {
      return new Chat_AIDL.Stub() {
          @Override
          public String passString(String message) throws RemoteException {
              return message;
          }
      };
  }
  
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
      userId = intent.getStringExtra("userId");
      publishTopic = "chat/+/" + userId + "/";
      subscribeTopic = "chat/#/" + userId + "/";
  
      Log.d("publishTopic", publishTopic);
      Log.d("subscribeTopic", subscribeTopic);
  
  
      establishMqttConnection();
  
      client.setCallback(new MqttCallback() {
          @Override
          public void connectionLost(Throwable cause) {
  
          }
  
          @Override
          public void messageArrived(String topic, MqttMessage receivedMessage) throws Exception {
              Intent in = new Intent();
              String msg = new String(receivedMessage.getPayload(), "UTF-8");
  
              in.putExtra("resultCode", Activity.RESULT_OK);
              in.putExtra("chatMsg", msg);
              Log.d("MQTT_RECEIVED", msg);
              LocalBroadcastManager.getInstance(getBaseContext()).sendBroadcast(in);
          }
  
          @Override
          public void deliveryComplete(IMqttDeliveryToken token) {
  
          }
      });
  
  
      Log.d("SERVICE_CHAT", "STICKY");
  
      super.onStartCommand(intent, flags, startId);
      return Service.START_STICKY;
  }
  
  private void establishMqttConnection() {
      MemoryPersistence memPer = new MemoryPersistence();
      client = new MqttAndroidClient(this, MQTT_BROKER, userId, memPer);
      try {
          client.connect(null, new IMqttActionListener() {
              @Override
              public void onSuccess(IMqttToken asyncActionToken) {
                  Log.d("MQTT", "SUCCESS");
                  subscribeMessage();
              }
  
              @Override
              public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
                  Log.d("MQTT", "FAILURE");
                  exception.printStackTrace();
              }
          });
      } catch (MqttException e) {
          e.printStackTrace();
      }
  }
  
  private void subscribeMessage() {
      try {
          client.subscribe(subscribeTopic, 0, null, new IMqttActionListener() {
              @Override
              public void onSuccess(IMqttToken asyncActionToken) {
  
              }
  
              @Override
              public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
  
              }
          });
      } catch (MqttSecurityException e) {
          e.printStackTrace();
      } catch (MqttException e) {
          e.printStackTrace();
      }
  }
  </code></pre>