I application for Native work light with the completion of NSRangeException a few minutes after a successful connection

I am using Worklight 6.0.0.1 + 9-26 iFix. A few minutes after a successful call to Worklight Connect, our application crashes with this error, which seems to include the JSON parsing problem from Worklight:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFConstantString substringWithRange:]: Range {2147483647, 1} out of bounds; string length 0'
*** First throw call stack:
(
    0   CoreFoundation                      0x021615e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x01ee48b6 objc_exception_throw + 44
    2   CoreFoundation                      0x021613bb +[NSException raise:format:] + 139
    3   CoreFoundation                      0x0213a5e8 -[__NSCFString substringWithRange:] + 136
    4   MyApp                           0x00036546 +[WLUtils parseJSONString:] + 230
    5   MyApp                           0x00032447 -[WLRequest requestFinished:] + 167
    6   libobjc.A.dylib                     0x01ef681f -[NSObject performSelector:withObject:] + 70
    7   MyApp                               0x00058a1b -[ASIHTTPRequest reportFinished] + 171
    8   libobjc.A.dylib                     0x01ef681f -[NSObject performSelector:withObject:] + 70
    9   Foundation                          0x01b39c18 __NSThreadPerformPerform + 285
    10  CoreFoundation                      0x020ea8af __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    11  CoreFoundation                      0x020ea23b __CFRunLoopDoSources0 + 235
    12  CoreFoundation                      0x0210730e __CFRunLoopRun + 910
    13  CoreFoundation                      0x02106b33 CFRunLoopRunSpecific + 467
    14  CoreFoundation                      0x0210694b CFRunLoopRunInMode + 123
    15  GraphicsServices                    0x0337f9d7 GSEventRunModal + 192
    16  GraphicsServices                    0x0337f7fe GSEventRun + 104
    17  UIKit                               0x00c5794b UIApplicationMain + 1225
    18  MyApp                               0x0000b9ad main + 141
    19  libdyld.dylib                       0x02abd725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException

We make the connection this way and get a successful response:

MyConnectListener *connectListener = [[MyConnectListener alloc] init];
[[WLClient sharedInstance] wlConnectWithDelegate:connectListener];


MyConnectListener implements WLDelegate

MyConnectListener.m:
-(void)onSuccess:(WLResponse *)response
{
    NSLog(@"Connection Success: %@", response);
}

-(void)onFailure:(WLFailResponse *)response
{
    NSLog(@"Connection failure: %@", response);
}

Any ideas how to solve this?

+4
source share
1 answer

This is reported as a defect and will be fixed in a future version. The current workaround is to disable heartbeat functionality using the following syntax:

[[WLClient sharedInstance] setHeartBeatInterval: -1];

+1
source

All Articles