Delay in events being raised

stevebates8 years ago

Hi guys,

I've having a problem with my Traccar install at the moment. Events are being raised as they happen when viewed via the web browser app, but the PHP script I have setup in event.forward.url appears to be delayed. This can be a few seconds to minutes sometimes. Mainly used for detecting entry and exit of geofences.

The script raises a notification at Pushover so initially i thought the delays may be there so i set the scripts to do 2 notifications at a time, one by email and one by Pushover. Both arrive at the same time so this is making me think the delays are Traccar side.

My configuration is as follows:


<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>

<properties>

    <entry key="config.default">./conf/default.xml</entry>
    
    <entry key='web.enable'>true</entry>
    <entry key='web.port'>8082</entry>
    <entry key='web.path'>./web</entry>
    <entry key="web.console">true</entry>
    
    <entry key='geocoder.enable'>true</entry>
    <entry key='geocoder.type'>nominatim</entry>
    <entry key='geocoder.url'>https://locationiq.org/v1/reverse.php</entry>
    <entry key='geocoder.key'>[removed]</entry>
    <entry key='geocoder.processInvalidPositions'>false</entry>
    
    <entry key="geolocation.enable">false</entry>
    <entry key="geolocation.type">mozilla</entry>
    <entry key="geolocation.processInvalidPositions">false</entry>
    
    <entry key="filter.enable">true</entry>
    <entry key="filter.limit">3</entry>
    <entry key="filter.invalid">true</entry>
    <entry key="filter.zero">true</entry>
    <entry key="filter.duplicate">false</entry>
    <entry key="filter.distance">30</entry>
    
    <entry key="distance.enable">true</entry>
    
    <entry key="logger.enable">true</entry>
    <entry key="logger.level">all</entry>
    
    <entry key="processing.copyAttributes.enable">false</entry>
    <entry key="processing.copyAttributes">battery,odometer,hours,temp1,io1,io2,io3,io4</entry>

    <entry key='database.driver'>com.mysql.jdbc.Driver</entry> 
    <entry key='database.url'>jdbc:mysql://127.0.0.1:3306/traccar?allowMultiQueries=true&autoReconnect=true&useSSL=false&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=''</entry>
    <entry key='database.user'>traccar</entry> 
    <entry key='database.password'>[removed]</entry>
    <entry key='database.ignoreUnknown'>false</entry>
    <entry key='database.registerUnknown'>true</entry>
    <entry key='database.saveOriginal'>true</entry>
    
    <entry key='coordinates.filter'>true</entry>
    <entry key='coordinates.error'>30</entry>
    
    <entry key="event.enable">true</entry>
    <entry key="event.overspeedHandler">true</entry>
    <entry key="event.overspeed.notRepeat">true</entry>
    <entry key="speedLimit">64</entry>
    <entry key="event.motionHandler">true</entry>
    <entry key="event.motion.speedThreshold">0.86</entry>
    <entry key="event.geofenceHandler">true</entry>
    <entry key="event.alertHandler">true</entry>
    <entry key="event.ignitionHandler">true</entry>
    
    <entry key="forward.enable">true</entry>
    <entry key='forward.url'>https://[removed]/traccar/position?name={name}&uniqueId={uniqueId}&deviceId={deviceId}&protocol={protocol}&deviceTime={deviceTime}&fixTime={fixTime}&valid={valid}&latitude={latitude}&longitude={longitude}&altitude={altitude}&speed={speed}&course={course}&statusCode={statusCode}&address={address}&attributes={attributes}&gprmc={gprmc}</entry>
    
    <entry key="event.forward.enable">true</entry>
    <entry key='event.forward.url'>https://[removed]/traccar/event?name={name}&uniqueId={uniqueId}&deviceId={deviceId}&protocol={protocol}&deviceTime={deviceTime}&fixTime={fixTime}&valid={valid}&latitude={latitude}&longitude={longitude}&altitude={altitude}&speed={speed}&course={course}&statusCode={statusCode}&address={address}&attributes={attributes}&gprmc={gprmc}</entry>
    
    <entry key="mail.smtp.host">localhost</entry>
    <entry key="mail.smtp.port">25</entry>
    
    <entry key="report.trip.minimalTripDuration">300</entry>
    <entry key="report.trip.minimalTripDistance">500</entry>
    <entry key="report.trip.minimalParkingDuration">300</entry>
    
</properties>

I've checked the system time which matches the device time however I've noticed the HTTP POST data that is sent to the event script is an hour behind. The server is installed on a Linode VPS dedicated to just Traccar, I've tried upgrading the VPS so adding an additional 1GB of RAM even though the manager pages reported extremely low resource uses.

I've checked some of the log messages and the location data appears to be coming through correctly.

The server is running with MySQL and the database size is around 419 MB.

There are about a total of 6 devices on the server, only 3 check in regular on 30 second intervals.

Is there anything in my config that could be causing these delays or any suggestions where to check? I've tried everything i can think of but not having much success.

Thanks,

Steve.

Anton Tananaev8 years ago

If you get events in the web app without delay, there should be no delay in forwarding either.

jaimzj8 years ago

Few suggestions based on my experience with setting up a php script to handle events. (If you see notification on traccar and receive the same event delayed via your php script) in such case I had already troubleshoot such a scenario with the following steps.

  1. See if your php script that handles these events, has any process or logic that takes time to process? any dependent service being called responds with a delay or no.?

  2. Easier method would be to write the event request to a log file (remove all the code from php file and capture the REQUESt and log to a text file) see the time difference if any exist or no. when an event is seen on traccar web, immediately check your log file if, that the event php script is written to it or no. (if no delay here).

check the script and response time from dependent services you are using to push the events further.

stevebates8 years ago

Hi guys,

Thank i've found the fault and fixed it last night in the early hours so couldnt test fully, off to try it in a moment.

In my scripts I had a total of 3 notification services, one of which appears to have been failing but forgotten about. The scripts logged when they were called etc and all timestamps seemed fine but for some reason the code must have been blocking and caused a delay to the whole thing.

Regards,

Steve.