# \[solved\] Java Already connected message

**URL:** <https://www.thethingsnetwork.org/forum/t/solved-java-already-connected-message/14353>\
**Category:** Home Automation\
**Created:** [May 20, 2018, 10:09am UTC](https://www.thethingsnetwork.org/forum/t/solved-java-already-connected-message/14353 "2018-05-20T10:09:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oberon](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/oberon/32/35697_2.png) [@oberon](https://www.thethingsnetwork.org/forum/u/oberon)\
**Post date:** [May 20, 2018, 10:09am UTC](https://www.thethingsnetwork.org/forum/t/solved-java-already-connected-message/14353/1 "2018-05-20T10:09:42Z")

</div>

Hello

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

And used the packet forwarder from:

> **[hallard/single\_chan\_pkt\_fwd](https://github.com/hallard/single_chan_pkt_fwd)**
>
> Single Channel LoRaWAN Gateway. Contribute to hallard/single\_chan\_pkt\_fwd development by creating an account on GitHub.

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](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!

---

<div class="post-metadata">

**Author:** ![oberon](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/oberon/32/35697_2.png) [@oberon](https://www.thethingsnetwork.org/forum/u/oberon)\
**Post date:** [May 30, 2018, 5:25am UTC](https://www.thethingsnetwork.org/forum/t/solved-java-already-connected-message/14353/3 "2018-05-30T05:25:45Z")

</div>

Hello

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

And used the packet forwarder from:

> **[hallard/single\_chan\_pkt\_fwd on GitHub](https://libraries.io/github/hallard/single_chan_pkt_fwd)**
>
> Single Channel LoRaWAN Gateway - a C++ repository on GitHub

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](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!

---

<div class="post-metadata">

**Author:** ![oberon](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/oberon/32/35697_2.png) [@oberon](https://www.thethingsnetwork.org/forum/u/oberon)\
**Post date:** [May 30, 2018, 5:47pm UTC](https://www.thethingsnetwork.org/forum/t/solved-java-already-connected-message/14353/4 "2018-05-30T17:47:19Z")

</div>

Finally found the answer.

Did put client.start before client.onError…

Stupid user mistake 😅

---

<div class="post-metadata">

**Author:** ![vinodtonda](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/vinodtonda/32/25844_2.png) [@vinodtonda](https://www.thethingsnetwork.org/forum/u/vinodtonda)\
**Post date:** [November 20, 2019, 11:44am UTC](https://www.thethingsnetwork.org/forum/t/solved-java-already-connected-message/14353/5 "2019-11-20T11:44:38Z")

</div>

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