Closed vbier closed 6 years ago
I am also running the Homematic binding on a Rpi 3 and never had this problem. But I am using the release version of openHAB2. As far as I can see there have been some refactorings in the RPC server implementation but the reconnect itself was not modified and at the moment I have no idea why this error occurs. According to the coding the port should be reused if it has not been freed completely. Maybe there is a problem in the socket implementation on the Rpi. In this case it may help to wait some (milli)seconds and try to connect again. I agree with you that it would be correct to set the state to OFFLINE if the reconnect fails.
I have added a delay of 500ms between the stopping of the server and the subsequent start. This seems to have fixed my problems, openHAB is now running for a few days with a restart interval of 60s without problems. This seems to confirm my theory of resources that are not yet released on restarting the server...
Thanks for the test and feedback. In this case I think it would be the best to implement a retry loop that tries to reconnect several times and if it fails sets the state to OFFLINE.
Due to the fact that the bindings cyclic reconnect has been replaced by proper connection tracking this is no longer a problem for me.
Every hour, the binding tries to restart the BIN-RPC server. From time to time, this fails with a BindException, presumably because the port is already in use (even though it was used by the binding without problems before the restarting the server).
Whenever the restart fails, the status of the bridge stays ONLINE, even though nothing works any more. The ReconnectThread simply logs a debug message and tries to connect again after the reconnect interval has expired. This attempt then succeeds and everything works again.
This is the stack trace of the exception when restarting the server fails:
Expected behavior would be that the restarting of the server works (the stop code should probably wait until resources have been freed). If this is not possible, than the binding should try to start the BIN-RPC server before the reconnect interval has expired (if the connection is gone, this is not exactly a reconnect scenario any more). At least the status should be set to OFFLINE so the user is aware of the fact that nothing works any more.
Openhab is running on a Raspberry Pi 3 with openhabian, openhab version is 2.1.0~2017-05-15.