Search code examples
javaclientmqttgateway

Can a PINGREQ message be used by a gateway to update a network address in MQTTSN


Im using an MQTTSN Gateway Version 1.2 from;

https://github.com/simon622/mqtt-sn

I notice that a when a client connection goes to sleep and then subsequently wakes up, its IP address may well have changed on the network. When the next PINGREQ message is sent by a client, the gateway is unable to establish its identity from the network address and so the session simply times out.

Is there anyway of updating the network address in this scenario to tie it back to the original session without having the overhead of a new CONNECT?

I tried issuing a new PINGREQ, but the gateway was unable to link the new network address to an existing gateway session.


Solution

  • You're correct in stating that a client may well recycle their IP address during a network event (ie. a network stack power down, or roaming between cells on a cellular network). These events typically require a completely new CONNECT to be issued in order to re-authenticate with a gateway, since typically in SN UDP implementations, the network address is used as part of the identification mechanism. You can CONNECT(clean=false) to maintain session state.

    Allowing a client to re-establish (or bind to an existing) session using a PINGREQ alone (with the presence of a clientId) would be very insecure and would present an easy attack vector for session hijacking.

    Hope this helps clarify things.