event.forward with problems?

macphisto7 years ago

Hi Guys,

I have installed 3.13 version and when i use enable.forward nothing is sended to remote app.
This is what remote app recieves when new event is triggered in traccar

 Tue, 15 Aug 2017 21:08:09 +0000        /app/traccar.php
 a:0:{}

Please any help will be appreciated

Anton Tananaev7 years ago

Official version of Traccar doesn't send anything like that.

macphisto7 years ago

Using the following code you can write everything was sent by POST method and nothing is detected so nothing was sent by traccar.
I followed all the instructions and before the update everything worked well

<?php
  $log_dir = '/tmp/';
  $log_name = "posts-" . $_SERVER['REMOTE_ADDR'] . "-" . date("Y-m-d-H") . ".log";
  $log_entry = gmdate('r') . "\t" . $_SERVER['REQUEST_URI'] . "
" . serialize($_POST) . "
" . $_POST['event']['type'] . "

";
  $fp=fopen( $log_dir . $log_name, 'a' );
  fputs($fp, $log_entry);
  fclose($fp);
?>
Anton Tananaev7 years ago

As far as I know, there were no major changes to event forwarding, so it should work exactly the same as before. I would recommend you to debug Traccar code, or at least get WireShark dump of the requests.

abyss7 years ago

Such code


<?php 
  $rest_json = file_get_contents("php://input");
  $_POST = json_decode($rest_json, true); 
  $log_dir = '/tmp/'; 
  $log_name = "posts-" . $_SERVER['REMOTE_ADDR'] . "-" . date("Y-m-d-H") . ".log"; 
  $log_entry = gmdate('r') . "\t" . $_SERVER['REQUEST_URI'] . "
" . serialize($_POST) . "
" . $_POST['event']['type'] . "
";
  $headers = apache_request_headers();

  foreach ($headers as $header => $value) {
      $log_entry = $log_entry . "$header: $value \n";
  }
  $fp=fopen( $log_dir . $log_name, 'a' ); 
  fputs($fp, $log_entry); 
  fclose($fp);
?>

produces such logs


Wed, 16 Aug 2017 07:09:17 +0000 /post.php
a:2:{s:5:"event";a:7:{s:2:"id";i:14829;s:10:"attributes";a:0:{}s:8:"deviceId";i:2;s:4:"type";s:12:"deviceOnline";s:10:"serverTime";s:28:"2017-08-16T07:09:16.994+0000";s:10:"positionId";i:0;s:10:"geofenceId";i:0;}s:6:"device";a:13:{s:2:"id";i:2;s:10:"attributes";a:5:{s:1$
deviceOnline
Content-Type: application/json; charset=utf-8
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
Content-Length: 580
Connection: keep-alive
Host: web01.rg.local
Accept: */*
User-Agent: AHC/1.0

Everything works