Error - String index out of range: 3 - StringIndexOutOfBoundsException

Danny Jul5 years ago

One of my Teltonika devices has been offline for a few days (No connection between server and tracking device).
It has therefore collected data for upload when the connection came back.
When they reconnected, uploading of the buffered data started, but after a while it was stopped by a data packet on which the server reports errors.

The tracking device therefore tries to upload the same package again and again.

Is there a way that I can either get the server to accept the package or skip it?

After all, I would like to have the following data packets in the buffer on the device.

Here is an upload attempt, all the attempts look the same, same data.

2019-11-27 12:30:40  INFO: [9e6a3c5a] connected
2019-11-27 12:30:40  INFO: [9e6a3c5a: teltonika < 109.59.3.106] HEX: 000f383634343033303433353539393330
2019-11-27 12:30:40  INFO: [9e6a3c5a: teltonika > 109.59.3.106] HEX: 01
2019-11-27 12:30:40  INFO: [9e6a3c5a: teltonika < 109.59.3.106] HEX: 000000000000048308080000016e91f068500005a07dc121e12201002200ed110016002008ef00f00150011503c8004501ed00712c11b5000ab60005420000180016cd702bce15eb430da94400000d059811fcd512ffc113031a0f00001900001a000056000068000004f100005cf9c700000000100226f3530c00025c7e030b00000000355114baee00000000000000000e00000001778382940000016e91f074080005a0713021e11d1f002100ee130023002008ef00f00150011503c8004501ed00712c11b50008b60005420000180023cd702bce15eb430daa4400000d059811fcfb12ffc813033a0f00001900001a000056000068000004f100000003c700000000100226f3670c00025c7e030b00000000355114baee00000000000000000e00000001778382940000016e91f07fc00005a05c7c21e115e5002000ee120030002008ef00f00150011503c8004501ed00712511b50008b60005420000180030cd702bce15eb430d584400000d059811fd0612ffd91303300f00001900001a000056000068000004f100005cf9c700000000100226f3880c00025c7e030b00000000355114baee00000000000000000e00000001778382940000016e91f08b780005a042f721e10c64002000ef13003b002008ef00f00150011503c8004501ed00712511b50008b6000542000018003bcd702bce15eb430d5c4400000d059811fd1112ffe91303270f00001900001a000056000068000004f100005cf9c700000000100226f3b50c00025c7e030b00000000355114baee00000000000000000e00000001778382940000016e91f09b180005a01afe21e0ffb2001d00ee130045002008ef00f00150011503c8004501ed00712711b50008b60005420000180045cd702bce15eb430d6c4400000d059811fd131200251302f80f00001900001a000056000068000004f100005cf9c700000000100226f3fb0c00025c7e030b00000000355114baee00000000000000000e00000001778382940000016e91f0aea000059fe31121e0ed34001a00ef120045002008ef00f00150011503c8004501ed00712311b50008b60005420000180045cd702bce15eb430d404400000d059811fd7812003c1303820f00001900001a000056000068000004f100005cf9c700000000100226f4600c00025c7e030b00000000355114baee00000000000000000e00000001778382940000016e91f0c22800059fb1c821e0dc36001b00ee13003b002008ef00f00150011503c8004501ed00712611b50008b6000542000018003bcd702bce15eb430d604400000d059811fc961200c413031a0f00001900001a000056000068000004f100005cf9c700000000100226f4bd0c00025c7e030b00000000355114baee00000000000000000e00000001778382940000016e91f0
2019-11-27 12:30:40  INFO: [9e6a3c5a: teltonika < 109.59.3.106] HEX: cde000059f99d321e0d3d0001a00ef130030002008ef00f00150011503c8004501ed00712711b50008b60005420000180030cd702bce15eb430d6f4400000d059811fc951200f813026e0f00001900001a000056000068000004f100005cf9c700000000100226f4ee0c00025c7e030b00000000355114baee00000000000000000e0000000177838294080000cc67
2019-11-27 12:30:40  WARN: [9e6a3c5a] error - String index out of range: 3 - StringIndexOutOfBoundsException (... < CellTower:111 < TeltonikaProtocolDecoder:350 < *:518 < *:548 < *:593 < *:583 < ExtendedObjectDecoder:51 < ...)
2019-11-27 12:30:40  INFO: [9e6a3c5a] disconnected
Anton Tananaev5 years ago

Your device is sending invalid operator field.

Danny Jul5 years ago

Hello Anton

Thank you for your response, I think that led me in the right direction.

The data from device looks valid when I use Teltonika Data Parser and process it as a "TCP AVL Data Packet".
But it seems that the data packet is so large that it is interpreted as two packets.
Then I just have to figure out where and why the data packet gets split in 2.

Somewhere, there must be a buffer that can only contain 1024 bytes ~ 2048 Hex characters.

Do you have any ideas?

Picture of data parsing

Danny Jul5 years ago

Hi again Anton

I went to Github and I think I found the problem.

What do you think?

Picture of data parsing

Anton Tananaev5 years ago

I think you are going in completely wrong direction.

Danny Jul5 years ago

Yep. But a good trip it was :-)

ANJUM SOHAIL3 years ago

@Danny Jul: could you plz send the Link to download Teltonika Data Parser Plz

Danny Jul3 years ago

@ANJUM SOHAIL:
I got the parser from a password protected customer area at Teltokika, so a shared link will not work, and I do not believe I have the right to distribute their software.
Please ask Teltonika support for what you need, and I think they will give it to you. Otherwise, if you are not a Teltonika customer yourself, ask your local dealer to get it for you.

And to @Anton Tananaev:
Thanks for telling me, that I was barking up the wrong tree, in this thread 2 years ago, it helped, and definitely saved me a lot of time :thumbsup:

ANJUM SOHAIL3 years ago

I got the link for the Parser Below
https://wiki.teltonika-networks.com/wikibase/images/c/c3/Teltonika_Parser_v1.6.zip

i have Same Problem here as well

2022-03-28 10:18:25  INFO: [daef3061: teltonika < 119.160.3.178] HEX: 00000000000000da08030000017fcedf499600280431be0eded45d0038012d100000fa100901000200b300b4004501500415034702fa00054232a1180000cd3b2fce281d43001f02c700000006f10000a029000000017fcedea99600280432070eded3dd00380046130009000f0801010200b300b400450150051502470205423276180009cd3b2fce281d43001f02c700000027f10000a0290000000179d50853180027f65d3f0ed67212001500f1110061000f0801010200b300b4004501500515034702054234f4180061cd53d1ce28c043003e02c700000147f1000000290003000052cb
2022-03-28 10:18:25  WARN: [daef3061] error - String index out of range: 3 - StringIndexOutOfBoundsException (... < CellTower:111 < TeltonikaProtocolDecoder:365 < *:533 < *:563 < *:608 < *:598 < ExtendedObjectDecoder:51 < ...)
2022-03-28 10:18:25  INFO: [daef3061] disconnected

The Problem i Found out was due to the device was sending invalid operator field, (i.e 41 only instead of 410)

Actually the code block below has an unhandled exception
traccar/src/org/traccar/model/CellTower.java

    public void setOperator(long operator) {
        String operatorString = String.valueOf(operator);
        mobileCountryCode = Integer.parseInt(operatorString.substring(0, 3));
        mobileNetworkCode = Integer.parseInt(operatorString.substring(3));
    }

The code block need to have try catch exception in above block to send a default operator code (if defined in default.xml) in such cases.

Anton Tananaev3 years ago