MQTT and bluemix

Hi,
Trying to use the MQTT library with bluemix on Photon. I am able to send ( publish) the mqtt message to bluemix. And I can see the message being parsed on bluemix, and output from bluemix.
I do not receive the message on Photon, as the code never executes the callback.

Should I have a mosquito server running on port 1883? I have an AT&T modem, on which I have opened the port 1883 ( or so I think!). How can I verify that the messages are indeed reaching the modem but not my photon which is wireless-ly attached to the AT&T modem.

Any help appreciated, thanks in advance, my code below

// This #include statement was automatically added by the Particle IDE.
 #include "SparkJson/SparkJson.h"

// This #include statement was automatically added by the Particle IDE.
 #include "MQTT/MQTT.h"

 #define LEDON HIGH
 #define LEDOFF LOW

int MYLED = D7; 

char server[] = "quickstart.messaging.internetofthings.ibmcloud.com";
char topic[] = "iot-2/evt/status/fmt/json";
char clientId[] = "d:quickstart:Photon:00FFBBCCDE10";
char authMethod[] = "use-token-auth"
char token[] ="my_unique_token"
char Ctrl = '0';

MQTT mqttClient(server, 1883, callback);

void BlinkMYLED() {   digitalWrite(MYLED, LEDON);  delay(250);  digitalWrite(MYLED, 

LEDOFF);  delay(250); }


void callback(char* topic, byte* payload, unsigned int length) {
    Serial.println("Called back.. do some processing!!");
    BlinkMYLED();
    Ctrl=0;
}

void setup() {
 
 pinMode(MYLED, OUTPUT);
 digitalWrite(MYLED, LEDOFF); 
 Serial1.begin(9600); 
  RGB.control(true);
  RGB.color(255,0,0);
  delay(2000);
  RGB.color(0,255,0);
  delay(2000);
  RGB.color(0,0,255);
  delay(2000);
  RGB.control(false);
  Serial.println(" "); // start on a new line
  mqttClient.connect(server);
  Serial.println("Done Setup & mqttsetup"); 

}

void sendToIOTF(String payload) {
    while (!mqttClient.isConnected()) { // If the Mqtt Client is not connected, so try to connect
        Serial.print("MQTT connection...");
        if (mqttClient.connect(clientId, authMethod, token)) { // Try to connect the Mqtt Client
            Serial.println("connected");
        } else {
            Serial.println("failed, MQTT connection");
            Serial.println(" try again in 1 second");
            delay(1000);
        }
    }
    mqttClient.publish(topic, (char*) payload.c_str()); // Send a message
    mqttClient.subscribe(topic);
}

void loop() {
 Ctrl= Serial.read(); 
 if ( Ctrl == 'P') {
      sendToIOTF("Yo! Am I there yet?");
      delay(100); 
  } 
}

hk101,

You should not need to open a port though your router. MQTT is a outgoing connection from the client (your device)

Do you intend to send yourself a message? Looks like you are subscribing to the same topic as you are publishing. I’m not sure the MQTT broker would send the message back to you.

Try using a web based MQTT client to receive and send messages. It should be fine to use the same topic for publish and subscribe, just that you may not receive the messages you send that way.

@uChobby,
Yes, I was intending to send a message to IBM bluemix, and have it echo back to me. Same topic. Even otherwise, I see that the bluemix mqtt broker service is sending a message but the callback is not being triggered.
Thank you for your comments, appreciate it.

If anyone has had any success from a simple echo message from photon to bluemix back to photon, that would be of great help.

Thanks