Nazmul Hasan February 2016

Thread 1 : EXC_BAD_ACCESS (Code = 1, address = 0x0) issue generated

I am using Paho MQTT (Internet of Things) With mobilefirst 7.1 for my hybrid application development (For iOS ,Android and windows phone devices). I tried with 'broker.mqttdashboard.com' for MQTT broker, but its not working for iOS .

error:

Xcode console:

libc++abi.dylib: Pure virtual function called!

main.js:

function wlCommonInit(){
     MQTTconnect(); //connect broker with subscribe 
}

mqttService.js:

var host = 'broker.mqttdashboard.com';
var port = 8000;
var topic = 'Sensor';   // topic to subscribe to
var useTLS = false;
var username = null;
var password = null;
// username = "Nazmul";
// password = "Kp0582!";
var cleansession = true;   

var mqtt;
    var reconnectTimeout = 2000;

    function MQTTconnect() {
        mqtt = new Paho.MQTT.Client(
                        host,
                        port,
                        "web_" + parseInt(Math.random() * 100,
                        10));
        var options = {
            timeout: 3,
            useSSL: useTLS,
            cleanSession: cleansession,
            onSuccess: onConnect,
            onFailure: function (message) {
                console.log("Connection failed: " + message.errorMessage + "Retrying")
                setTimeout(MQTTconnect, reconnectTimeout);
            }
    };

        mqtt.onConnectionLost = onConnectionLost;
        mqtt.onMessageArrived = onMessageArrived;

        if (username != null) {
            options.userName = username;
            options.password = password;
        }
        console.log("Host="+ host + ", port=" + port + " TLS = " + useTLS + " username=" + username + " password=" + password);
        mqtt.connect(options);
    };

    function onConnect() {

        console.log('Connected to ' + host + ':' + port)
        // Connection succeeded; subscribe to our t        

Answers


PhaniRaghu February 2016

int retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
return retVal;


Shehzad Ali February 2016

Please verify your appdelegate class name. Is it MyAppDelegate. If so, import MyAppDelegate.h over it. If still it isn't working then replace your code by this code.

int main(int argc, char * argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([MyAppDelegate class]));
    }
}


Nazmul Hasan February 2016

it was a null reference error that the editor didn't catch - it ran only in code available on the iPhone.

Null reference errors: because always javascript file did not load. object throwing this error.

Now this way it is working

main.js:

function wlCommonInit(){

      $(document).ready(function(){
           MQTTconnect(); //connect broker with subscribe         
       });

  }

Post Status

Asked in February 2016
Viewed 1,219 times
Voted 13
Answered 3 times

Search




Leave an answer