How do I send a GET request from a coap server to a device running outside the local network?

We have a device running inside the local network, and the californium server runs on a separate machine outside the network. The IP segment is public. the requirement is that when a server receives a request from a device, the server must respond to a GET request to the device. The problem we are facing is when the device sends a request to the server, the server cannot see the internal IP of the device, the server can only see the external IP of the device (the public IP of the network). So the server grabs the IP and PORT numbers from the request and creates a separate receive request, configures the IP address and port for it, and sends the request to the device. the request only reached the public IP address of the network and could not reach the device. Is there a wayto which server can send a GET request to the device instead of sending a message to the public IP?

One more thing, when the server sends a copy back to the device, the response is sent to the device and not blocked on the public IP of the device. I am posting a response to the device using the following code:

handleGET(CoapExchange exchange){
    exchange.respond("");   //respnoding with empty payload

}

      

Thanks in advance...

+3


source to share


1 answer


This should work if you are sending a message to the client in less than 30 seconds. This is what we do with leshan http://github.com/jvermillard/leshan . It uses Californium to implement Lightweight M2M and it works the same way you are trying to achieve.



+1


source







All Articles