if (client.connect("ESP8266Client", mqtt_username, mqtt_password)) {
See the latest pubsubclient ESP example which generates a random client name for every connection.
Serial.print("Attempting MQTT connection...");
// Create a random client ID
String clientId = "ESP8266Client-";
clientId += String(random(0xffff), HEX);
// Attempt to connect
if (client.connect(clientId.c_str())) {
If the problem persists, turn on verbose debug on the MQTT server to see if and why it is disconnecting clients. Wireshark captures might be helpful.