mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 01:27:34 -05:00
#132 - adds enhanced streaming connection error handling. Adds specific handler for connection timeout to reset the connection.
This commit is contained in:
@@ -240,19 +240,38 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
|
|||||||
@Override
|
@Override
|
||||||
public void exceptionCaught(IoSession session, Throwable cause) throws Exception
|
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");
|
String reason = ioe.getMessage();
|
||||||
disconnect();
|
|
||||||
connect();
|
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
|
else
|
||||||
{
|
{
|
||||||
mLog.error("IO Exception", ioe);
|
setBroadcastState(BroadcastState.ERROR);
|
||||||
|
disconnect();
|
||||||
|
mLog.error("Unspecified IO error - streaming halted.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -241,19 +241,38 @@ public class ShoutcastV1AudioBroadcaster extends AudioBroadcaster
|
|||||||
@Override
|
@Override
|
||||||
public void exceptionCaught(IoSession session, Throwable cause) throws Exception
|
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");
|
String reason = ioe.getMessage();
|
||||||
disconnect();
|
|
||||||
connect();
|
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
|
else
|
||||||
{
|
{
|
||||||
mLog.error("IO Exception", ioe);
|
setBroadcastState(BroadcastState.ERROR);
|
||||||
|
disconnect();
|
||||||
|
mLog.error("Unspecified IO error - streaming halted.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -356,19 +356,38 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
|
|||||||
@Override
|
@Override
|
||||||
public void exceptionCaught(IoSession session, Throwable cause) throws Exception
|
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");
|
String reason = ioe.getMessage();
|
||||||
disconnect();
|
|
||||||
connect();
|
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
|
else
|
||||||
{
|
{
|
||||||
mLog.error("IO Exception", ioe);
|
setBroadcastState(BroadcastState.ERROR);
|
||||||
|
disconnect();
|
||||||
|
mLog.error("Unspecified IO error - streaming halted.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user