Merge pull request #134 from DSheirer/132-streaming_error_socket_timeout

#132 - adds enhanced streaming connection error handling.  Adds speci…
This commit is contained in:
Denny Sheirer
2017-01-24 19:31:00 -05:00
committed by GitHub
3 changed files with 78 additions and 21 deletions

View File

@@ -240,19 +240,38 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
@Override
public void exceptionCaught(IoSession session, Throwable cause) throws Exception
{
if(cause instanceof IOException && ((IOException) cause).getMessage().startsWith("Connection reset"))
if(cause instanceof IOException)
{
IOException ioe = (IOException) cause;
IOException ioe = (IOException)cause;
if(ioe.getMessage() != null && ioe.getMessage().startsWith("Connection reset"))
if(ioe.getMessage() != null)
{
mLog.info("Streaming connection reset by remote server - reestablishing connection");
disconnect();
connect();
String reason = ioe.getMessage();
if(reason.startsWith("Connection reset"))
{
mLog.info("Streaming connection reset by remote server - reestablishing connection");
disconnect();
connect();
}
else if(reason.startsWith("Operation timed out"))
{
mLog.info("Streaming connection timed out - resetting connection");
disconnect();
connect();
}
else
{
setBroadcastState(BroadcastState.ERROR);
disconnect();
mLog.error("Unrecognized IO error: " + reason + ". Streaming halted.");
}
}
else
{
mLog.error("IO Exception", ioe);
setBroadcastState(BroadcastState.ERROR);
disconnect();
mLog.error("Unspecified IO error - streaming halted.");
}
}
else

View File

@@ -241,19 +241,38 @@ public class ShoutcastV1AudioBroadcaster extends AudioBroadcaster
@Override
public void exceptionCaught(IoSession session, Throwable cause) throws Exception
{
if(cause instanceof IOException && ((IOException) cause).getMessage().startsWith("Connection reset"))
if(cause instanceof IOException)
{
IOException ioe = (IOException) cause;
IOException ioe = (IOException)cause;
if(ioe.getMessage() != null && ioe.getMessage().startsWith("Connection reset"))
if(ioe.getMessage() != null)
{
mLog.info("Streaming connection reset by remote server - reestablishing connection");
disconnect();
connect();
String reason = ioe.getMessage();
if(reason.startsWith("Connection reset"))
{
mLog.info("Streaming connection reset by remote server - reestablishing connection");
disconnect();
connect();
}
else if(reason.startsWith("Operation timed out"))
{
mLog.info("Streaming connection timed out - resetting connection");
disconnect();
connect();
}
else
{
setBroadcastState(BroadcastState.ERROR);
disconnect();
mLog.error("Unrecognized IO error: " + reason + ". Streaming halted.");
}
}
else
{
mLog.error("IO Exception", ioe);
setBroadcastState(BroadcastState.ERROR);
disconnect();
mLog.error("Unspecified IO error - streaming halted.");
}
}
else

View File

@@ -356,19 +356,38 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
@Override
public void exceptionCaught(IoSession session, Throwable cause) throws Exception
{
if(cause instanceof IOException && ((IOException) cause).getMessage().startsWith("Connection reset"))
if(cause instanceof IOException)
{
IOException ioe = (IOException) cause;
IOException ioe = (IOException)cause;
if(ioe.getMessage() != null && ioe.getMessage().startsWith("Connection reset"))
if(ioe.getMessage() != null)
{
mLog.info("Streaming connection reset by remote server - reestablishing connection");
disconnect();
connect();
String reason = ioe.getMessage();
if(reason.startsWith("Connection reset"))
{
mLog.info("Streaming connection reset by remote server - reestablishing connection");
disconnect();
connect();
}
else if(reason.startsWith("Operation timed out"))
{
mLog.info("Streaming connection timed out - resetting connection");
disconnect();
connect();
}
else
{
setBroadcastState(BroadcastState.ERROR);
disconnect();
mLog.error("Unrecognized IO error: " + reason + ". Streaming halted.");
}
}
else
{
mLog.error("IO Exception", ioe);
setBroadcastState(BroadcastState.ERROR);
disconnect();
mLog.error("Unspecified IO error - streaming halted.");
}
}
else