Commit 97a17d0849a1b76ed99dee09d371bb6afa2c7bd1
1 parent
b11c57d4
修正用户停止播放后API代理抛错误问题
Showing
1 changed file
with
6 additions
and
10 deletions
src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
| @@ -2,8 +2,7 @@ package com.genersoft.iot.vmp.conf; | @@ -2,8 +2,7 @@ package com.genersoft.iot.vmp.conf; | ||
| 2 | 2 | ||
| 3 | import org.apache.http.HttpRequest; | 3 | import org.apache.http.HttpRequest; |
| 4 | import org.apache.http.HttpResponse; | 4 | import org.apache.http.HttpResponse; |
| 5 | -import org.apache.http.client.config.RequestConfig; | ||
| 6 | -import org.apache.http.impl.client.HttpClientBuilder; | 5 | +import org.apache.catalina.connector.ClientAbortException; |
| 7 | import org.mitre.dsmiley.httpproxy.ProxyServlet; | 6 | import org.mitre.dsmiley.httpproxy.ProxyServlet; |
| 8 | import org.slf4j.Logger; | 7 | import org.slf4j.Logger; |
| 9 | import org.slf4j.LoggerFactory; | 8 | import org.slf4j.LoggerFactory; |
| @@ -14,16 +13,11 @@ import org.springframework.context.annotation.Configuration; | @@ -14,16 +13,11 @@ import org.springframework.context.annotation.Configuration; | ||
| 14 | import org.springframework.util.StringUtils; | 13 | import org.springframework.util.StringUtils; |
| 15 | 14 | ||
| 16 | import javax.servlet.ServletException; | 15 | import javax.servlet.ServletException; |
| 17 | -import javax.servlet.ServletRequest; | ||
| 18 | -import javax.servlet.ServletResponse; | ||
| 19 | import javax.servlet.http.HttpServletRequest; | 16 | import javax.servlet.http.HttpServletRequest; |
| 20 | -import javax.servlet.http.HttpServletResponse; | ||
| 21 | import java.io.IOException; | 17 | import java.io.IOException; |
| 22 | import java.net.ConnectException; | 18 | import java.net.ConnectException; |
| 23 | -import java.util.Locale; | ||
| 24 | -import java.util.Map; | ||
| 25 | - | ||
| 26 | 19 | ||
| 20 | +@SuppressWarnings(value = {"rawtypes", "unchecked"}) | ||
| 27 | @Configuration | 21 | @Configuration |
| 28 | public class ProxyServletConfig { | 22 | public class ProxyServletConfig { |
| 29 | 23 | ||
| @@ -61,7 +55,7 @@ public class ProxyServletConfig { | @@ -61,7 +55,7 @@ public class ProxyServletConfig { | ||
| 61 | 55 | ||
| 62 | @Override | 56 | @Override |
| 63 | protected void handleRequestException(HttpRequest proxyRequest, HttpResponse proxyResonse, Exception e){ | 57 | protected void handleRequestException(HttpRequest proxyRequest, HttpResponse proxyResonse, Exception e){ |
| 64 | - System.out.println(e.getMessage()); | 58 | + //System.out.println(e.getMessage()); |
| 65 | try { | 59 | try { |
| 66 | super.handleRequestException(proxyRequest, proxyResonse, e); | 60 | super.handleRequestException(proxyRequest, proxyResonse, e); |
| 67 | } catch (ServletException servletException) { | 61 | } catch (ServletException servletException) { |
| @@ -69,7 +63,9 @@ public class ProxyServletConfig { | @@ -69,7 +63,9 @@ public class ProxyServletConfig { | ||
| 69 | } catch (IOException ioException) { | 63 | } catch (IOException ioException) { |
| 70 | if (ioException instanceof ConnectException) { | 64 | if (ioException instanceof ConnectException) { |
| 71 | logger.error("zlm 连接失败"); | 65 | logger.error("zlm 连接失败"); |
| 72 | - }else { | 66 | + } else if (ioException instanceof ClientAbortException) { |
| 67 | + logger.error("用户已中断连接,代理终止"); | ||
| 68 | + } else { | ||
| 73 | logger.error("zlm 代理失败: ", e); | 69 | logger.error("zlm 代理失败: ", e); |
| 74 | } | 70 | } |
| 75 | } catch (RuntimeException exception){ | 71 | } catch (RuntimeException exception){ |