# Problems receiving downlinks using the Java API

**URL:** <https://www.thethingsnetwork.org/forum/t/problems-receiving-downlinks-using-the-java-api/5877>\
**Category:** Application Development\
**Created:** [March 6, 2017, 4:35pm UTC](https://www.thethingsnetwork.org/forum/t/problems-receiving-downlinks-using-the-java-api/5877 "2017-03-06T16:35:20Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![wanssemd](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/wanssemd/32/35697_2.png) [@wanssemd](https://www.thethingsnetwork.org/forum/u/wanssemd)\
**Post date:** [March 7, 2017, 9:15am UTC](https://www.thethingsnetwork.org/forum/t/problems-receiving-downlinks-using-the-java-api/5877/6 "2017-03-07T09:15:31Z")

</div>

Thanks for the answers.

> [@cambierr](#):
>
> What version of the java sdk are you using ?

I’m using version 1.0.0 due to the circumstances described [here](https://www.thethingsnetwork.org/forum/t/java-sdk-cannot-resolve-dependancy/4513).

> [@htdvisser](#):
>
> To minimize the delay caused by network latency, we recommend to place your application server close to the Handler (Ireland for eu, California for us-west, Sao Paulo for brazil, Singapore for asia-se).

I’m working from Germany and am using the EU application server but still have a delay of about 500 ms till the data is actually received and processed by the Java API on server side. This may be caused by the size of the data payload which is most of the time about 115 Byte.

This is one shortened part of the application which tends to make problems. I try to respond directly to an uplink message. Is this a problem?

```
client.onMessage(new BiConsumer<String, Object>() {
		@Override
		public void accept(String _devID, Object _data) {
			System.out.println("Message: " + _devID + " " + _data);
			try {
                JSONObject jobject = (JSONObject) _data;
	        	if (jobject.get("port").equals(49) && !sending) {

					int i, checkCtr;
					Object test = jobject.get("payload_raw");

                    //---------------------------------
                    //some computations with object test
                    //---------------------------------

					// application acks 
					if (i == checkCtr) {
						client.send(_devID, new String("DUPLICATE").getBytes(), 1);				
                        return;
					} else if (i != checkCtr - 1) {
						client.send(_devID, new String("ERROR").getBytes(), 1);
						Arrays.fill(fragData, (byte) 0);
						fragment = false;
						return;
					} else {	
			         	checkCtr = i;
						client.send(_devID,	new String("OK").getBytes(), 1);
             		}

				} catch (Exception ex) {
				    System.out.println("Response failed: " + ex.getMessage());
			    }
		}
});

```

Do I need to let the responses get queued first and then send another uplink message which is just intended to receive the last queued downlink before I proceed with the actual application messages?

---

_[View the full topic](https://www.thethingsnetwork.org/forum/t/problems-receiving-downlinks-using-the-java-api/5877)._
