Why ALLJOYN server is crashing?

asked 2015-08-24 06:02:34 -0700

Dipayan gravatar image

updated 2015-08-25 10:04:18 -0700

ry.jones gravatar image
Linux Foundation Staff

I am trying to make an app using ALLJOYN. Instead of using it as a chat sample i have tried to use it as an server which will give me response on basis of my request. I have used ALLJOYN sdks code to connect and disconnect.

Here i am posting the code which i have tried. If i make a single request in one connection and disconnect it and try to connect again I can connect for 4 times consecutively and in the 5th time server is crashing (in my side the session id is becoming 0)but if i do multiple requests and disconnect it and try to make connection again the server is getting crashed.Please let me know if anyone has any idea how to stop the server crashing.Thank you in advance. I have also marked the delegate method's line after which the server is crashing.

-(void)connect{
QStatus status = ER_OK;

    self.busAttachment = [[AJNBusAttachment alloc] initWithApplicationName:kAppName allowRemoteMessages:YES];

    AJNInterfaceDescription* chatInterface = [self.busAttachment createInterfaceWithName:kInterfaceName];
    status = [chatInterface addSignalWithName:@"Chat" inputSignature:@"s" argumentNames:[NSArray arrayWithObject:@"str"]];

    if (status != ER_OK && status != ER_BUS_MEMBER_ALREADY_EXISTS) {
        @throw [NSException exceptionWithName:@"BusObjectInitFailed" reason:@"Unable to add method to interface: cat" userInfo:nil];
    }
    else
    {
    }

    [chatInterface activate];

    // register signal handler
    //
    self.chatObjectSignalHandler = [[AJNCChatObjectSignalHandler alloc] init];
    self.chatObjectSignalHandler.delegate=nil;
    self.chatObjectSignalHandler.delegate = self;

    [self.busAttachment registerSignalHandler:self.chatObjectSignalHandler];     //registering signal handler

    //   app.chatObjectSignalHandlerGlobal=self.chatObjectSignalHandler;
    // create and register the chat bus object
    //
    self.chatObject = [[AJNCBusObject alloc] initWithBusAttachment:self.busAttachment onServicePath:kServicePath];

    self.chatObject.delegate = self;

    [self.busAttachment registerBusObject:self.chatObject]; //registering bus

    // start the bus
    //
    status = [self.busAttachment start];
    if (status != ER_OK) {
        NSLog(@"ERROR: Failed to start bus. %@", [AJNStatus descriptionForStatusCode:status]);

    }
    else{
        NSLog(@"bus started succesfully");
    }

    // register our view controller as the bus listener
    //
    [self.busAttachment registerBusListener:self];
    //
    // connect to the bus
    //
    status = [self.busAttachment connectWithArguments:@"null:"];
    if (status != ER_OK) {
        NSLog(@"ERROR: Failed to connect bus. %@", [AJNStatus descriptionForStatusCode:status]);

    }
    else{
        NSLog(@"bus connected succesfully");
    }

    if (gMessageFlags == kAJNMessageFlagSessionless) {
        NSLog(@"Adding match rule : [%@]", self.sessionlessSignalMatchRule);
        status = [self.busAttachment addMatchRule:self.sessionlessSignalMatchRule];

        if (status != ER_OK) {
            //   NSLog(@"ERROR: Unable to %@ match rule.  @"remove" : @"add", [AJNStatus descriptionForStatusCode:status]);
            NSLog(@"Error:unable to match rule");
        }
    }
    else {
        serviceName = [NSString stringWithFormat:@"%@%@", kServiceName, @"chat"];
        status=[self.busAttachment findAdvertisedName:serviceName];
        if (status!=ER_OK) {
            NSLog(@"didnot find");
        } else {
            NSLog(@"found the advesrtiser");
        }
    }
}

-(void)disconnect:(LoginViewController *) ob {


    NSString *serviceName = [NSString stringWithFormat:@"%@%@", kServiceName, @"chat"];

    // leave the chat session
    //
    [ob.busAttachment leaveSession:ob.sessionId];

    // cancel the advertised name search, or the advertisement, depending on if this is a
    // service or client
    //

        [ob.busAttachment cancelAdvertisedName:serviceName withTransportMask:kAJNTransportMaskAny];


    // disconnect from the bus
    //
    [ob.busAttachment disconnectWithArguments:@"null:"];

    // unregister our listeners and the chat bus object
    //
    [ob.busAttachment unregisterBusListener:ob];

    [ob.busAttachment unregisterSignalHandler:ob.chatObjectSignalHandler];

    [ob.busAttachment unregisterBusObject:ob.chatObject];

    // stop the bus and wait for the stop operation to complete
    //
    [ob.busAttachment stop];

    [self.busAttachment waitUntilStopCompleted];

    // dispose of everything
    //
    ob.chatObjectSignalHandler.delegate = nil;
    ob.chatObjectSignalHandler = nil;

    ob.chatObject.delegate = nil;
    ob.chatObject = nil;

    ob.busAttachment = nil;

}


bus register delegate method:
#pragma mark - AJNBusListener delegate methods

- (void)didFindAdvertisedName:(NSString *)name withTransportMask:(AJNTransportMask ...
(more)
edit retag flag offensive close merge delete

Comments

you might try on the core mailing list. https://lists.allseenalliance.org/mailman/listinfo/allseen-core

ry.jones ( 2015-08-25 09:19:56 -0700 )edit

Thanks.. I will give it a try. Meanwhile, I will try to add more information if it helps. We are actually hosting a server built in .NET and we have 2 clients. One is Android and another is iOS. We are making service calls through chat messages and the problems occurs only when we have made around

Dipayan ( 2015-08-25 10:13:08 -0700 )edit

4-5 calls and then kill the app in iPad or Android and then reopen it and then why it tries to join the session it gives the following error: ER_ALLJOYN_JOINSESSION_REPLY_UNREACHABLE QStatus status = self.busAttachment->JoinSession([sessionName UTF8String], sessionPort, listenerImpl, sessionId, *(

Dipayan ( 2015-08-25 10:14:25 -0700 )edit

the objective C binding is no longer supported, I would recommend you look at using C++. Also it would be helpful if you described a little bit about the system set up: what platform is your server running on? what is running on android? what is running on iOS?

marcello ( 2015-08-26 15:53:19 -0700 )edit

sure I can describe. Server is running on C#.net with AlljoynUnity dll in C++. The crash occurs in Alljoyn Unity DLL. Both Android and iOS are clients based on the sample chat application from Alljoyn available in Github. They are making calls in JSON to the server through chat messages.

Dipayan ( 2015-08-28 10:33:17 -0700 )edit