Index: asterisk-22.8.2/res/res_musiconhold.c
===================================================================
--- asterisk-22.8.2.orig/res/res_musiconhold.c
+++ asterisk-22.8.2/res/res_musiconhold.c
@@ -413,7 +413,9 @@ static int moh_files_next(struct ast_cha
 		state->samples = 0;
 	}
 
+	ast_debug(1, "Got %zu files to try.\n", file_count);
 	for (tries = 0; tries < file_count; ++tries) {
+		ast_debug(1, "Trying file '%s'\n", AST_VECTOR_GET(files, state->pos));
 		if (ast_openstream_full(chan, AST_VECTOR_GET(files, state->pos), ast_channel_language(chan), 1)) {
 			break;
 		}
@@ -424,6 +426,8 @@ static int moh_files_next(struct ast_cha
 	}
 
 	if (tries == file_count) {
+		ast_log(LOG_WARNING, "Reached maximum tries. Aborting.");
+		ao2_t_unlink(mohclasses, state->class, "Removing MOH class from container");
 		ao2_ref(files, -1);
 		return -1;
 	}
@@ -521,6 +525,7 @@ static int moh_files_generator(struct as
 		ast_channel_lock(chan);
 		f = moh_files_readframe(chan);
 		if (!f) {
+ 			ast_log(LOG_WARNING, "Could not read frame for '%s'", state->class->name);
 			ast_channel_unlock(chan);
 			return -1;
 		}
