KNX2 stopps working after a while (received disconnect response status 0x21)

I solved it by programming a service restart every time it goes offline.

I got the result by creating in my raspberry openhabian installation this sh file (install sshpass before with: apt-get install sshpass):

// restartknx.sh
sudo -u [YOUR_SYSTEM_USER] sshpass -p [YOUR_SYSTEM_PASSWORD] ssh openhab@localhost -p 8101 'bundle:restart org.openhab.binding.knx'

and running it by this cron rule:

rule "Restart KNX"

when
        
	Time cron "0/10 * * ? * *" 

then
  
	val allThings = sendHttpGetRequest("http://192.168.1.81:8080/rest/things")

	  if(allThings.indexOf('BRIDGE_OFFLINE"},"editable":false,"label":"KNK [ATT] 1.1.4')>0){
	
    logInfo("KNX", "KNX Autorestart")
    
	    var String esito = executeCommandLine("/etc/openhab2/scripts/restartknx.sh",5000)

	    if(esito!=''){
      
	        logInfo("KNX", "Autorestart completed (" + esito +")")
    
	    }
	
  }

end

In the sh file I check offline thing status searching “BRIDGE_OFFLINE”},“editable”:false,“label”:“KNK [ATT] 1.1.4” string into json sendHttpGetRequest result. This is a specific string of a my knx thing and you must search a your specific different string.

Remember to change [YOUR_SYSTEM_USER] and [YOUR_SYSTEM_PASSWORD] with your openhabian credentials of a my knx thing and you can search a your specific different string.