Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracker sends same records again and again #10

Open
lukasreusch opened this issue Jul 9, 2022 · 11 comments
Open

Tracker sends same records again and again #10

lukasreusch opened this issue Jul 9, 2022 · 11 comments

Comments

@lukasreusch
Copy link

lukasreusch commented Jul 9, 2022

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);
        }
@lukasreusch
Copy link
Author

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....

@lukasreusch
Copy link
Author

@uro can you help?

@uro
Copy link
Owner

uro commented Aug 14, 2022

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.

@algirdas-iterato
Copy link
Contributor

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.

@uro
Copy link
Owner

uro commented Sep 21, 2023

Hey @algirdas-iterato did you solve this issue?

@salboy
Copy link

salboy commented Oct 25, 2023

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?``

@uro
Copy link
Owner

uro commented Oct 25, 2023

@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

@salboy

This comment was marked as outdated.

@MPE-Danitech
Copy link

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

@youb22
Copy link

youb22 commented Apr 20, 2024

@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!

@MPE-Danitech
Copy link

Thanks @Du22. I'll try that next time I play with the FMB965.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants