ivanfmartinez / ivanfm-traccar-mqtt

mqtt handler for traccar
14 stars 6 forks source link

How to install ivanfm-traccar-mqtt? #4

Open hubecker opened 6 years ago

hubecker commented 6 years ago

Hi, I was able to build 2 jar files: ivanfm-traccar-mqtt-2.2.1-jar-with-dependencies.jar ivanfm-traccar-mqtt-2.2.1.jar copied them to the lib folder of traccar and added the following in my traccar.xml: <entry key='extra.handlers'>"com.ivanfm.traccar.MQTTHandler"</entry> <entry key='mqtt.url'>tcp://localhost:1883</entry> <entry key='mqtt.clientid'>traccar.mqtt.handler</entry> <entry key='mqtt.topicRoot'>_traccar/</entry>

But when starting traccar i see in the log file: 2018-11-18 22:02:33 INFO: Starting server... 2018-11-18 22:02:33 WARN: Dynamic handler error - "com.ivanfm.traccar.MQTTHandler" - ClassNotFoundException (... < BasePipelineFactory:331 < *:291 < ...)

What's the right way to integrate ivanfm-traccar-mqtt? Thanks and regards

Hubert

jsponz commented 5 years ago

@hubecker Any update on this? Do you have it working?

hubecker commented 5 years ago

No, since nobody answered here i don't know how to get it working.

jsponz commented 5 years ago

Thanks. Did you find any alternative solution?

ivanfmartinez commented 5 years ago

I did not see this message before. The error is in the double quotes :

the class name com.ivanfm.traccar.MQTTHandler should not be enclosed in the double quotes

remove the double quotes from the class name.

jsponz commented 5 years ago

Thanks.

Could you write down some lines in order to know the installation process?

It shouldn't take you so much... but it will help a lot!

Thanks!

hubecker commented 5 years ago

Same problem without the quotes. 2019-05-21 15:16:25 INFO: Starting server... 2019-05-21 15:16:26 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < *:130 < ...)

ivanfmartinez commented 5 years ago

The jar must be in your classpath. How you are running traccar ? which classpath ? Where do you place the jar ?

On Tue, May 21, 2019 at 10:35 AM Hubert Becker notifications@github.com wrote:

Same problem without the quotes. 2019-05-21 15:16:25 INFO: Starting server... 2019-05-21 15:16:26 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < *:130 < ...)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ivanfmartinez/ivanfm-traccar-mqtt/issues/4?email_source=notifications&email_token=AAFFJCNSZM3FSNWPT3K5V4LPWP3ATA5CNFSM4GFASEN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV35SNI#issuecomment-494393653, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFFJCJBQYKTVVE7MSGLMH3PWP3ATANCNFSM4GFASENQ .

hubecker commented 5 years ago

they are in /opt/traccar/lib:

/opt/traccar/lib# ll iv* -rw-r--r-- 1 root root 212640 Nov 13 2018 ivanfm-traccar-mqtt-2.2.1-jar-with-dependencies.jar -rw-r--r-- 1 root root 12388 Nov 13 2018 ivanfm-traccar-mqtt-2.2.1.jar

ivanfmartinez commented 5 years ago

only the jar-with-dependencies is enough, no need for both jars.

The log shows the full stacktrace ?

Which version of traccar ?

I did not have updated this repo with some changes that are necessary for new releases. I will pushthe changes later. As now someone is testing.

ivanfmartinez commented 5 years ago

I have pushed the changes that I have used for 4.3

I did not have tested with newer versions.

hubecker commented 5 years ago

I am using latest release of traccar 4.5. So i will wait for the changes and then test again. Thanks

ivanfmartinez commented 5 years ago

I have compiled on version agains 4.5, could you test ?

https://filedn.com/l8OQOK51ql1J391d2ApmLb0/tmp/ivanfm-traccar-mqtt-2.2.3-jar-with-dependencies-4.5.jar

In case of error pelase send the full stacktrace,

jsponz commented 5 years ago

Hi,

I just made a fresh installation of traccar.

Place your file under /opt/traccar/lib/

Add the following lines to config file:

com.ivanfm.traccar.MQTTHandler tcp://localhost:1883 _traccar

and I get this:

2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 09:48:29 INFO: jetty-9.4.18.v20190429; built: 2019-04-29T20:42:08.989Z; git: e1bc35120a6617ee3df052294e433f3a25ce7097; jvm 11.0.3-ojdkbuild+7 2019-05-22 09:48:30 INFO: Started o.t.w.@2450256f{/,null,AVAILABLE} 2019-05-22 09:48:30 INFO: DefaultSessionIdManager workerName=node0 2019-05-22 09:48:30 INFO: No SessionScavenger set, using defaults 2019-05-22 09:48:30 INFO: node0 Scavenging every 600000ms 2019-05-22 09:48:31 INFO: Started o.e.j.s.ServletContextHandler@6ed691fd{/,null,AVAILABLE} 2019-05-22 09:48:31 WARN: Web server start failed - Address already in use - BindException (... < WebServer:159 < Main:118 < *:104) root@development:/opt/traccar/logs#

hubecker commented 5 years ago

Same for me

ivanfmartinez commented 5 years ago

Please set logger.fullStackTraces with true value in your configuration.

ivanfmartinez commented 5 years ago

I have one idea about what is wrong. And to confirm, you should respond the questions that I made before :

How you are running traccar ? (the exactly command line) which classpath is used ?

just putting in the lib folder will not add the jar to the classpath because the MANIFEST was created in the compilation time.

If you are running like this :

https://www.traccar.org/manual-installation/

java -jar tracker-server.jar conf/traccar.xml

you should change the command to

java -cp ivanfm-traccar-mqtt-2.2.3-jar-with-dependencies-4.5.jar -jar tracker-server.jar conf/traccar.xml

or point to the mqtt jar in your CLASSPATH environment before executing traccar.

hubecker commented 5 years ago

Traccar is startet by the /etc/init.d/traccar file which startr traccar in this way:

startit() { echo "Starting traccar ..." java -Dwrapper.pidfile=/run/wrapper.traccar.pid -Dwrapper.service=true -Dwrapper.visible=false -Djna_tmpdir=/opt/traccar/tmp -jar /opt/traccar/wrapper.jar -tx /opt/traccar/conf/wrapper.conf }

jsponz commented 5 years ago

I followed the standard instructions. It is run by systemctl Content of the file: /etc/systemd/system/traccar.service

[Unit] Description=traccar After=network.target

[Service] Type=simple WorkingDirectory=/opt/traccar ExecStart=/opt/traccar/jre/bin/java -Djdk.tls.client.protocols=TLSv1.2 -cp ivanfm-traccar-mqtt-2.2.3-jar-with-dependencies-4.5.jar -jar tracker-server.jar$ SyslogIdentifier=traccar SuccessExitStatus=143

[Install] WantedBy=multi-user.target

But I still get the same message...

ivanfmartinez commented 5 years ago

As you are using an startup script that maybe is not in the correct path. put the full path for the -cp parameter in the java command line

like

-cp /opt/traccar/lib/ivanfm-traccar-mqtt-2.2.3-jar-with-dependencies-4.5.jar -jar

jsponz commented 5 years ago

No difference. Same result :-(

ivanfmartinez commented 5 years ago

have you included the logger.fullStackTraces as true in your config ?

Without a full stacktrace I cannot see any other possible problem.

jsponz commented 5 years ago

@ivanfmartinez I found something...

2019-05-22 21:27:36 INFO: Operating system name: Linux version: 4.4.0-109-generic architecture: amd64 2019-05-22 21:27:36 INFO: Java runtime name: OpenJDK 64-Bit Server VM vendor: Oracle Corporation version: 11.0.3-ojdkbuild+7 2019-05-22 21:27:36 INFO: Memory limit heap: 502mb non-heap: 0mb 2019-05-22 21:27:36 INFO: Character encoding: UTF-8 charset: UTF-8 2019-05-22 21:27:36 INFO: Version: 4.4 2019-05-22 21:27:36 INFO: Starting server... 2019-05-22 21:27:36 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 21:27:36 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 21:27:36 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 21:27:36 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 21:27:36 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 21:27:36 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 21:27:36 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 21:27:36 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 21:27:36 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 21:27:36 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler - ClassNotFoundException (... < BasePipelineFactory:165 < :130 < ...) 2019-05-22 21:27:36 WARN: Dynamic handler error - com.ivanfm.traccar.MQTTHandler -

I have reinstalled the server again with the file (traccar-linux-64-4.5.zip) from here: https://www.traccar.org/download/

and it still says Version: 4.4

Does it help?

jsponz commented 5 years ago

have you included the logger.fullStackTraces as true in your config ?

Without a full stacktrace I cannot see any other possible problem.

Yes, I did:

2019-05-23 00:06:36 WARN: Dynamic handler error - java.lang.ClassNotFoundException: com.ivanfm.traccar.MQTTHandler at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:315) at org.traccar.BasePipelineFactory.addDynamicHandlers(BasePipelineFactory.java:165) at org.traccar.BasePipelineFactory.initChannel(BasePipelineFactory.java:130) at io.netty.channel.ChannelInitializer.initChannel(ChannelInitializer.java:129) at io.netty.channel.ChannelInitializer.handlerAdded(ChannelInitializer.java:112) at io.netty.channel.AbstractChannelHandlerContext.callHandlerAdded(AbstractChannelHandlerContext.java:969) at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:610) at io.netty.channel.DefaultChannelPipeline.access$100(DefaultChannelPipeline.java:46) at io.netty.channel.DefaultChannelPipeline$PendingHandlerAddedTask.execute(DefaultChannelPipeline.java:1461) at io.netty.channel.DefaultChannelPipeline.callHandlerAddedForAllHandlers(DefaultChannelPipeline.java:1126) at io.netty.channel.DefaultChannelPipeline.invokeHandlerAddedIfNeeded(DefaultChannelPipeline.java:651) at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:515) at io.netty.channel.AbstractChannel$AbstractUnsafe.access$200(AbstractChannel.java:428) at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:487) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:405) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834)

ivanfmartinez commented 5 years ago

Now I think I found the error.

The classname in README is wrong. Probably from an early version.

the correct is :

com.ivanfm.traccar.mqtt.MQTTHandler

Please change the xml for the correct classname. I have corrected the README.

About the wrong version in 4.5 traccar, it should be reported in the official repo issues.

jsponz commented 5 years ago

Hi, I have updated it and restarted the server.

Same result :-(

2019-05-23 06:49:52 WARN: Dynamic handler error - java.lang.ClassNotFoundException: com.ivanfm.traccar.mqtt.MQTTHandler at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:315) at org.traccar.BasePipelineFactory.addDynamicHandlers(BasePipelineFactory.java:165) at org.traccar.BasePipelineFactory.initChannel(BasePipelineFactory.java:130) at io.netty.channel.ChannelInitializer.initChannel(ChannelInitializer.java:129) at io.netty.channel.ChannelInitializer.handlerAdded(ChannelInitializer.java:112) at io.netty.channel.AbstractChannelHandlerContext.callHandlerAdded(AbstractChannelHandlerContext.java:969) at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:610) at io.netty.channel.DefaultChannelPipeline.access$100(DefaultChannelPipeline.java:46) at io.netty.channel.DefaultChannelPipeline$PendingHandlerAddedTask.execute(DefaultChannelPipeline.java:1461) at io.netty.channel.DefaultChannelPipeline.callHandlerAddedForAllHandlers(DefaultChannelPipeline.java:1126) at io.netty.channel.DefaultChannelPipeline.invokeHandlerAddedIfNeeded(DefaultChannelPipeline.java:651) at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:515) at io.netty.channel.AbstractChannel$AbstractUnsafe.access$200(AbstractChannel.java:428) at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:487) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:405) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834)

hubecker commented 5 years ago

Same for me Version number is already reported: https://www.traccar.org/forums/topic/traccar-45-version-string/

ivanfmartinez commented 5 years ago

I have some time and have tested with a fresh installation (downloaded the zip and made manual installation as in traccar website https://www.traccar.org/download/ ) and found that java is not respecting the -cp parameter with -jar.

the -jar parameter must be removed and the

command should be like this

java -cp /path/ivanfm-traccar.mqtt...jar:/path/tracker-server.jar org.traccar.Main /path/conf/traccar.xml

please put the full paths for the jars and the config file, or if you are sure about the path you are running you can use the relative path.

jsponz commented 5 years ago

Thanks for the hint, but still no success and the server is shutting down:

2019-05-23 16:36:09 WARN: Dynamic handler error - java.lang.ClassNotFoundException: com.ivanfm.traccar.mqtt.MQTTHandler at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:315) at org.traccar.BasePipelineFactory.addDynamicHandlers(BasePipelineFactory.java:165) at org.traccar.BasePipelineFactory.initChannel(BasePipelineFactory.java:130) at io.netty.channel.ChannelInitializer.initChannel(ChannelInitializer.java:129) at io.netty.channel.ChannelInitializer.handlerAdded(ChannelInitializer.java:112) at io.netty.channel.AbstractChannelHandlerContext.callHandlerAdded(AbstractChannelHandlerContext.java:969) at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:610) at io.netty.channel.DefaultChannelPipeline.access$100(DefaultChannelPipeline.java:46) at io.netty.channel.DefaultChannelPipeline$PendingHandlerAddedTask.execute(DefaultChannelPipeline.java:1461) at io.netty.channel.DefaultChannelPipeline.callHandlerAddedForAllHandlers(DefaultChannelPipeline.java:1126) at io.netty.channel.DefaultChannelPipeline.invokeHandlerAddedIfNeeded(DefaultChannelPipeline.java:651) at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:515) at io.netty.channel.AbstractChannel$AbstractUnsafe.access$200(AbstractChannel.java:428) at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:487) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:405) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834)

2019-05-23 16:36:09 INFO: jetty-9.4.18.v20190429; built: 2019-04-29T20:42:08.989Z; git: e1bc35120a6617ee3df052294e433f3a25ce7097; jvm 11.0.3-ojdkbuild+7 2019-05-23 16:36:09 INFO: Started o.t.w.@2450256f{/,null,AVAILABLE} 2019-05-23 16:36:09 INFO: DefaultSessionIdManager workerName=node0 2019-05-23 16:36:09 INFO: No SessionScavenger set, using defaults 2019-05-23 16:36:09 INFO: node0 Scavenging every 660000ms 2019-05-23 16:36:10 INFO: Started o.e.j.s.ServletContextHandler@69bc4024{/,null,AVAILABLE} 2019-05-23 16:36:10 INFO: Started ServerConnector@5d43409a{HTTP/1.1,[http/1.1]}{0.0.0.0:8082} 2019-05-23 16:36:10 INFO: Started @8046ms 2019-05-23 16:36:11 INFO: Shutting down server...

My files are:

1) /etc/systemd/system/traccar.service

[Unit] Description=traccar After=network.target

[Service] Type=simple WorkingDirectory=/opt/traccar

ExecStart=/opt/traccar/jre/bin/java -cp /opt/traccar/lib/ivanfm-traccar-mqtt-2.2.3-jar-with-dependencies.jar -Djdk.tls.client.protocols=TLSv1.2 /opt/traccar/tracker-server.jar org.traccar.Main /opt/traccar/conf/traccar.xml

SyslogIdentifier=traccar SuccessExitStatus=143

[Install] WantedBy=multi-user.target

2) traccar.conf

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

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

./conf/default.xml org.h2.Driver jdbc:h2:./data/database sa com.ivanfm.traccar.mqtt.MQTTHandler tcp://localhost:1883 traccar.mqtt.handler /traccar/ true nominatim https://eu1.locationiq.com/v1/reverse.php 12345678 true
jsponz commented 5 years ago

If I remove -jar, server shuts down...

ivanfmartinez commented 5 years ago

The jars must be separated by ":"

the line you sent was :

ExecStart=/opt/traccar/jre/bin/java -cp /opt/traccar/lib/ivanfm-traccar-mqtt-2.2.3-jar-with-dependencies.jar -Djdk.tls.client.protocols=TLSv1.2 /opt/traccar/tracker-server.jar org.traccar.Main /opt/traccar/conf/traccar.xml

it should be

ExecStart=/opt/traccar/jre/bin/java -cp /opt/traccar/lib/ivanfm-traccar-mqtt-2.2.3-jar-with-dependencies.jar:/opt/traccar/tracker-server.jar -Djdk.tls.client.protocols=TLSv1.2 org.traccar.Main /opt/traccar/conf/traccar.xml

jsponz commented 5 years ago

Thanks @ivanfmartinez

Now at least the server is running... I updated the file with your line.

But I still get:

2019-05-23 20:40:54 WARN: Dynamic handler error - java.lang.ClassNotFoundException: com.ivanfm.traccar.mqtt.MQTTHandler at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:315) at org.traccar.BasePipelineFactory.addDynamicHandlers(BasePipelineFactory.java:165) at org.traccar.BasePipelineFactory.initChannel(BasePipelineFactory.java:130) at io.netty.channel.ChannelInitializer.initChannel(ChannelInitializer.java:129) at io.netty.channel.ChannelInitializer.handlerAdded(ChannelInitializer.java:112) at io.netty.channel.AbstractChannelHandlerContext.callHandlerAdded(AbstractChannelHandlerContext.java:969) at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:610) at io.netty.channel.DefaultChannelPipeline.access$100(DefaultChannelPipeline.java:46) at io.netty.channel.DefaultChannelPipeline$PendingHandlerAddedTask.execute(DefaultChannelPipeline.java:1461) at io.netty.channel.DefaultChannelPipeline.callHandlerAddedForAllHandlers(DefaultChannelPipeline.java:1126) at io.netty.channel.DefaultChannelPipeline.invokeHandlerAddedIfNeeded(DefaultChannelPipeline.java:651) at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:515) at io.netty.channel.AbstractChannel$AbstractUnsafe.access$200(AbstractChannel.java:428) at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:487) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:405) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834)

2019-05-23 20:40:54 INFO: jetty-9.4.18.v20190429; built: 2019-04-29T20:42:08.989Z; git: e1bc35120a6617ee3df052294e433f3a25ce7097; jvm 11.0.3-ojdkbuild+7 2019-05-23 20:40:54 INFO: Started o.t.w.@4466cf5d{/,null,AVAILABLE} 2019-05-23 20:40:54 INFO: DefaultSessionIdManager workerName=node0 2019-05-23 20:40:54 INFO: No SessionScavenger set, using defaults 2019-05-23 20:40:54 INFO: node0 Scavenging every 600000ms 2019-05-23 20:40:56 INFO: Started o.e.j.s.ServletContextHandler@20f63ddc{/,null,AVAILABLE} 2019-05-23 20:40:56 INFO: Started ServerConnector@4649d70a{HTTP/1.1,[http/1.1]}{0.0.0.0:8082} 2019-05-23 20:40:56 INFO: Started @8790ms

ivanfmartinez commented 5 years ago

the ivanfm,...jar can be read by the traccar user ?

please set logger.level as finest in the traccar.xml remove the current log file, restart .

save the log file check if there are no passwords in the log and share the file...

In my case when it is working it shows in the log this line showing that it can read the jar :

2019-05-23 10:37:41 DEBUG: Opening jar:file:/mnt/dados/ivanfm/java/ivanfm/ivanfm-traccar-mqtt/target/ivanfm-traccar-mqtt-2.2.3-jar-with-dependencies.jar!/META-INF/MANIFEST.MF as META-INF/MANIFEST.MF

jsponz commented 5 years ago

Still not working.

Could you please describe the process you followed from the installation of traccar to the installation of your code? I think something is missing.

Thanks for your help!

hubecker commented 5 years ago

Since i start traccar via /et/init.d/traccar, where in fact the wrapper.jar is startet: java -Dwrapper.pidfile=/run/wrapper.traccar.pid -Dwrapper.service=true -Dwrapper.visible=false -Djna_tmpdir=/opt/traccar/tmp -jar /opt/traccar/wrapper.jar -tx /opt/traccar/conf/wrapper.conf

i changed my wrapper. conf and added the following line: wrapper.java.classpath.lib=/opt/traccar/lib/*.jar

Working fine now for me Now i am testing.

Thanks for your help!

jsponz commented 5 years ago

@hubecker Could you please describe the process you followed from the installation of traccar to the installation of the code? I think something is missing.

I am using sudo ./traccar.run for the installation and reboot the server after the installation. Traccar is manage by systemctl.

Thanks!

hubecker commented 5 years ago

That's what i did too. And again i am using the init.d script.

ivanfmartinez commented 5 years ago

Still not working.

Could you please describe the process you followed from the installation of traccar to the installation of your code? I think something is missing.

Thanks for your help!

In my latest test I have downloaded the zip from : https://www.traccar.org/download/

uncompressed the zip in my /tmp/traccar

changed the xml with my configuration data , changed the current directory to traccar folder /tmp/traccar and executed with

java -cp /path/ivanfm-traccar.mqtt...jar:tracker-server.jar org.traccar.Main conf/traccar.xml

If not running directly you must check your environment to put the jar in your classpath. What I have discovered in my environment is that if I use the -jar parameter it will ignore the -cp parameter.

jsponz commented 5 years ago

@ivanfmartinez Thanks! Finally it works. I have to run it manually.

It connects to my broker or to localhost broker:

/traccar/start Fri May 24 23:30:32 CEST 2019 /traccar/start Fri May 24 23:46:17 CEST 2019 /traccar/start Fri May 24 23:49:00 CEST 2019

but it does not send anything. Please find attached the log file for your review.

tracker-server.log.mqtt.txt

ivanfmartinez commented 5 years ago

The stacktrace is related to the value defined in

mqtt.alarmTopics (you should use this name currently) or mqtt.alarmTopic

If this value has spaces, this exception will happen.

I will make changes later to ignore this problem.

jsponz commented 5 years ago

Actually, I don't make any definition of "device configuration parameters". Should I make it in traccar.xml?

Thanks!

ivanfmartinez commented 5 years ago

I have updated the readme to indicate as device attributes.

The device attributes are optional and should be only defined if necessary.

I have updated the code in the repo to work fine if there are any wrong value for alarmTopics now.

Please compile a new version from repo or download again the file from this link :

https://filedn.com/l8OQOK51ql1J391d2ApmLb0/tmp/ivanfm-traccar-mqtt-2.2.3-jar-with-dependencies-4.5.jar

jsponz commented 5 years ago

Thanks. It works now :-) I really appreciate your help and support.

I had to make a manual installation with manual starting of the application (I need to look into this).

As endpoint, I see "fixtime", which is 2 hours less than my server.

Time on the server and on the traccar app is right: "Sun May 26 15:46:22 CEST 2019 ", but the endpoint says: device/b4305201b526600001/fixtime 2019-05-26T13:46:22Z

Any idea?

ivanfmartinez commented 5 years ago

fixtime is in ISO format UTC timezone.

Apears to be correct to me :

[ivanfm@p2x4 ~]$ TZ=UTC date -d "Sun May 26 15:46:22 CEST 2019" Sun May 26 13:46:22 UTC 2019

Do you need it in localtime ? Your integration does not support ISO time format with timezone (Z)?

If you find what is the problem with your other running format please send an change for the README indicating the procedure.

draksh1 commented 4 years ago

Hi ivanfmartinez,

Thanks for giving an approach to communicate with Mqtt. Now I am able to connect to Mqtt using the approach you mentioned above. I think the solution is to publish the device data to Mqtt. Is it possible to update the positions and send the real time Mqtt data to traccar web? I am trying to connect secured MQTT using SSL/TLS. In the Mqtthandler Handle position method is never getting invoked. So tried to call getPublisher() method in the constructor of MQTTHandler. My goal is to update the device positions onMessageArrived.