11:27:44.002 [UDP-Sender-localhost/127.0.0.1:0[0]] DEBUG org.eclipse.californium.elements.UDPConnector - UDPConnector (Thread[UDP-Sender-localhost/127.0.0.1:0[0],5,Californium/Elements]) sent 120 bytes to ztd-coap-nlb-f9adbad5e5c4bbcd.elb.us-west-1.amazonaws.com/54.176.11.0:5684
11:27:44.002 [CoapServer(main)#1] DEBUG org.eclipse.californium.core.network.Exchange - local Exchange[L1, complete] completed CON-POST MID=58500, Token=F8CCB2FEC737AF83, OptionSet={"Uri-Path":"bs", "Uri-Query":["pct=112","ep=localhost","deviceId=ODkwMTE3MDMyNzgyODg3Nzc1NjE6MzU0NzYyMTE0MDc5ODQwMQ%3D%3D","ip=72.163.220.9"]}, canceled <empty data>!
11:27:44.001 [RegistrationEngine#0] WARN org.eclipse.leshan.client.engine.DefaultRegistrationEngine - Unable to send Bootstrap request
org.eclipse.leshan.core.request.exception.SendFailedException: Request CON-POST MID=58500, Token=F8CCB2FEC737AF83, OptionSet={"Uri-Path":"bs", "Uri-Query":["pct=112","ep=localhost","deviceId=ODkwMTE3MDMyNzgyODg3Nzc1NjE6MzU0NzYyMTE0MDc5ODQwMQ%3D%3D","ip=72.163.220.9"]}, Can't assign requested address <empty data> cannot be sent
at org.eclipse.leshan.core.californium.CoapSyncRequestObserver.onSendError(CoapSyncRequestObserver.java:106)
at org.eclipse.californium.core.coap.Message.setSendError(Message.java:1026)
at org.eclipse.californium.core.coap.Request.setSendError(Request.java:1046)
at org.eclipse.californium.core.network.CoapEndpoint$SendingCallback.onError(CoapEndpoint.java:1246)
at org.eclipse.californium.elements.RawData.onError(RawData.java:314)
at org.eclipse.californium.elements.UDPConnector$Sender.work(UDPConnector.java:518)
at org.eclipse.californium.elements.UDPConnector$NetworkStageThread.run(UDPConnector.java:434)
Caused by: java.io.IOException: Can't assign requested address
at java.base/java.net.PlainDatagramSocketImpl.send(Native Method)
at java.base/java.net.DatagramSocket.send(DatagramSocket.java:695)
at org.eclipse.californium.elements.UDPConnector$Sender.work(UDPConnector.java:515)
... 1 common frames omitted
I realised the mistake. I have this code modified .
builder.setLocalAddress(cli.main.localAddress, cli.main.localPort);
to
builder.setLocalAddress(“localhost”, 5684);. (Mistake I did). The datagram socket gets opened for 127.0.0.1, which is why it works locally.
I had to bind this to any IP with 0.0.0.0
Thank you for your support @boaks / @sbernard31