Tracker sends same records again and again
Hey guys,
I am trying to collect some data from my FMB965. In general I am able to collect the data and writing it to a database.
But I have the problem, that tracker sends the same records again and again. The Last Server Response Time in the Configurator says 01.01.1970 01:00:00 (so, never?).
Something wrong with the Acknowledge-stuff?
Thank you!!
$ip = env('SOCKET_SERVER_IP');
$port = env('SOCKET_SERVER_PORT');
$parser = new FmParser('tcp');
$socket = stream_socket_server("tcp://$ip:$port", $errno, $errstr);
$this->info("Listening to tcp://{$ip}:{$port}...");
if (!$socket) {
throw new \Exception("$errstr ($errno)");
} else {
while ($conn = stream_socket_accept($socket)) {
// Read IMEI
$payload = fread($conn, 1024);
$imei = $parser->decodeImei($payload);
// Accept packet
fwrite($conn, Reply::accept());
// Read Data
$payload="";
while( !feof( $conn ) ) {
$payload .= fread( $conn, 1024 ) ;
}
$packet = $parser->decodeData($payload);
fwrite($conn, $parser->encodeAcknowledge($packet));
foreach ($packet->getAvlDataCollection()->getAvlData() as $avlData) {
$gps = $avlData->getGpsElement();
// Create it in DB
$this->info('Record created');
}
fclose($conn);
}
fclose($socket);
}
I've now debugged a little bit more. The number of data bytes, sent with the payload, is matching the count of records I create from the data. And this, is matching the numberOfData of the collectino. So, I don't see any problems here.
Even if I use the numberOfData-bytes from the payload directly and return it with pack('N', ...), the tracker ignores it....
@uro can you help?
Hey @lukasreusch
Hmm, thinking about it now. It looks like the tracker is not acknowledging received data and resending it.
Just in case, could you confirm on the teltonika configurator that the device can receive data? I see this as a problem if the amount of received data is 0. Otherwise, we can validate the checksums.
Hi,
I believe the same problem appeared to me. When the tracker sends the AVL package it hopes to get a response with a count of packages that were received.
`[2022.10.06 14:23:07]-[NETWORK.PARSER] Parsing data from 0 socket, data len: 5
DUMP DATA START: 01 00 00 00 15 DUMP DATA END
[2022.10.06 14:23:07]-[NETWORK.PARSER] Server: 0, Record ACK received: 16777216, expected 21`
Don't know why, but the tracker receives "01" at the beginning of message.
Hey @algirdas-iterato did you solve this issue?
Hi @uro or anyone with solution to this issue. i write below code but yet still i receive the same gps location again and again
fwrite($conn,"\x01");
fwrite($conn, $parser->encodeAcknowledge($packet));
fwrite($conn, Reply::accept());
Anyone with a solution to this?``
@salboy
I don't have any teltonika device atm. As you can find in the docs, the device will resend the payload if the confirmation checksum that you reply with does not match.
I would validate what data you use to calculate the checksum. Then I would check what they expect.
[2022.10.06 14:23:07]-[NETWORK.PARSER] Server: 0, Record ACK received: 16777216, expected 21`
This example shows an obvious problem here. Just check why they want you to send them 21. Is there something we're not reading from the device?
I would also check for any updates to the teltonika software; maybe there is a new contract and something changed on the communication level.
I can implement some changes but won't do the early debugging. Please help to find the issue. Thanks
@uro Here is my linkedin www.linkedin.com/in/salieu-sallah-a63575b4 please connect and debug if possible .
Thanks
Hi @uro
I have the same problem with the FMB965. It continue to sent the same records.
Did you solve your problem?
Thanks in advance
@lukasreusch @salboy @uro @MPE-Danitech
I got the same problem and solved it by providing the time to the device (FMxxx) to process the acknowledge from the server. Just add a sleep(1) between the fwrite and fclose was enough :
fwrite($conn, $parser->encodeAcknowledge($packet));
sleep(1)
fclose($conn);
I hope it helps!
Thanks @du22. I'll try that next time I play with the FMB965.