Why does a TiNG API call return ERR_SM_WRONG_CHANNEL_STATE?
Another operation is in progress. For example, a replay was started, sm_replay_abort() was called, but the application did not wait for sm_replay_status() to indicate that the replay had completed.
Ensure that the application waits correctly for each operation to complete see When are the various operations on a channel complete?" in the Prosody overview.