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

How to install ivanfm-traccar-mqtt? #4

Open
hubecker opened this issue Nov 18, 2018 · 44 comments
Open

How to install ivanfm-traccar-mqtt? #4

hubecker opened this issue Nov 18, 2018 · 44 comments

Comments

@hubecker
Copy link

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
Copy link

jsponz commented May 21, 2019

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

@hubecker
Copy link
Author

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

@jsponz
Copy link

jsponz commented May 21, 2019

Thanks. Did you find any alternative solution?

@ivanfmartinez
Copy link
Owner

ivanfmartinez commented May 21, 2019

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
Copy link

jsponz commented May 21, 2019

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
Copy link
Author

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
Copy link
Owner

ivanfmartinez commented May 21, 2019 via email

@hubecker
Copy link
Author

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
Copy link
Owner

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
Copy link
Owner

I have pushed the changes that I have used for 4.3

I did not have tested with newer versions.

@hubecker
Copy link
Author

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

@ivanfmartinez
Copy link
Owner

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
Copy link

jsponz commented May 22, 2019

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
Copy link
Author

Same for me

@ivanfmartinez
Copy link
Owner

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

@ivanfmartinez
Copy link
Owner

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
Copy link
Author

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
Copy link

jsponz commented May 22, 2019

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
Copy link
Owner

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
Copy link

jsponz commented May 22, 2019

No difference. Same result :-(

@ivanfmartinez
Copy link
Owner

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

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

@jsponz
Copy link

jsponz commented May 22, 2019

@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
Copy link

jsponz commented May 22, 2019

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
Copy link
Owner

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
Copy link

jsponz commented May 23, 2019

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
Copy link
Author

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

@ivanfmartinez
Copy link
Owner

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
Copy link

jsponz commented May 23, 2019

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

  1. traccar.conf
<entry key='config.default'>./conf/default.xml</entry>

<!--

This is the main configuration file. All your configuration parameters should be placed in this file.

Default configuration parameters are located in the "default.xml" file. You should not modify it to avoid issues
with upgrading to a new version. Parameters in the main config file override values in the default file. Do not
remove "config.default" parameter from this file unless you know what you are doing.

For list of available parameters see following page: https://www.traccar.org/configuration-file/

-->

<entry key='database.driver'>org.h2.Driver</entry>
<entry key='database.url'>jdbc:h2:./data/database</entry>
<entry key='database.user'>sa</entry>
<entry key='database.password'></entry>

com.ivanfm.traccar.mqtt.MQTTHandler
tcp://localhost:1883
traccar.mqtt.handler
/traccar/

true
nominatim
https://eu1.locationiq.com/v1/reverse.php
12345678

true

@jsponz
Copy link

jsponz commented May 23, 2019

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

@ivanfmartinez
Copy link
Owner

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
Copy link

jsponz commented May 23, 2019

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
Copy link
Owner

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
Copy link

jsponz commented May 24, 2019

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
Copy link
Author

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
Copy link

jsponz commented May 24, 2019

@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
Copy link
Author

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

@ivanfmartinez
Copy link
Owner

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
Copy link

jsponz commented May 24, 2019

@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
Copy link
Owner

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
Copy link

jsponz commented May 25, 2019

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

Thanks!

@ivanfmartinez
Copy link
Owner

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
Copy link

jsponz commented May 26, 2019

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
Copy link
Owner

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
Copy link

draksh1 commented Nov 19, 2020

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.

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

4 participants