[solved] Java Already connected message

Hello

I followed the tutorial:
https://www.thingforward.io/techblog/2017-09-27-getting-started-with-lorawan-thethingsnetwork-and-platformio.html

And used the packet forwarder from:

All is working fine .

And now I’m trying the Java tutorial on TTN Client:
https://www.thethingsnetwork.org/docs/applications/java/quick-start.html

However when I’m trying to connect I get the following error message:
java.lang.RuntimeException: Already connected
at org.thethingsnetwork.data.mqtt.Client.onError (Client.java:406)
at nl.ttn.TTNClient.main (TTNClient.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282)
at java.lang.Thread.run (Thread.java:748)

Any idea why?

Thnx!

Hello

I followed the tutorial:
https://www.thingforward.io/techblog/2017-09-27-getting-started-with-lorawan-thethingsnetwork-and-platformio.html 1

And used the packet forwarder from:

All is working fine. I see messages in the console.

Then tried the Python client example and this is also working fine.

Now I’m trying the Java tutorial on TTN Client:
https://www.thethingsnetwork.org/docs/applications/java/quick-start.html 3

However when I’m trying to connect I get the following error message:
java.lang.RuntimeException: Already connected
at org.thethingsnetwork.data.mqtt.Client.onError (Client.java:406)
at nl.ttn.TTNClient.main (TTNClient.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282)
at java.lang.Thread.run (Thread.java:748)

Any idea why?

Thnx!

Finally found the answer.

Did put client.start before client.onError…

Stupid user mistake :sweat_smile:

1 Like

We are getting the same error as you got but in our case we put the client start before the client.onError.
Any idea ?