If i add some uuid to the identifier, it works fine. But with the same identifier, if i deploy the code newly, it could happen that the subscribtion doesn’t work . Could you give me some suggestion?
it is great to see your interest in MQTT and HiveMQ client library! If a client with the same client id connects to the broker, the broker should disconnect that client that connected using this client id earlier.
Following questions could help to understand the issue that you are experiencing better:
When you deploy the code newly, are the previous instances of the client 100% offline?
What reconnect strategy your client has? For example, is it trying to reconnect at all times?
Is your client logging what is happening? (use log level TRACE for detailed logging)
When you are saying the subscription does not work, what do you actually see: an exception, an error or an info line in the logs?
When you deploy the code newly, are the previous instances of the client 100% offline?
Yes, the client is running in a docker container and by deployment the old container will be replaced by the new one
What reconnect strategy your client has? For example, is it trying to reconnect at all times?
As the code above i use the automaticReconnectWithDefaultConfig, it am not sure but it should try to reconnect all times, all right?
Is your client logging what is happening? (use log level TRACE for detailed logging)
I will try it
When you are saying the subscription does not work, what do you actually see: an exception, an error or an info line in the logs?
There is no exception, but the client could not receive any Message.