搭建turbine时 hystrix MaxConcurrentConnections reached 异常
2017-03-28 10:04:47.438 ERROR 1035 --- [InstanceMonitor] c.n.t.monitor.instance.InstanceMonitor : Could not initiate connection to host, giving up: [{"timestamp":1490666687435,"status":503,"error":"Service Unavailable","message":"MaxConcurrentConnections reached: 5","path":"/hystrix.stream"}]
~/.m2/repository/com/netflix/hystrix/hystrix-metrics-event-stream/1.5.6/hystrix-metrics-event-stream-1.5.6-sources.jar!/com/netflix/hystrix/contrib/requests/stream/HystrixRequestEventsSseServlet.java
public class HystrixRequestEventsSseServlet extends HystrixSampleSseServlet {
private static final long serialVersionUID = 6389353893099737870L;
/* used to track number of connections and throttle */
private static AtomicInteger concurrentConnections = new AtomicInteger(0);
private static DynamicIntProperty maxConcurrentConnections =
DynamicPropertyFactory.getInstance().getIntProperty("hystrix.config.stream.maxConcurrentConnections", 5);
//......
}
~/.m2/repository/com/netflix/hystrix/hystrix-metrics-event-stream/1.5.6/hystrix-metrics-event-stream-1.5.6-sources.jar!/com/netflix/hystrix/contrib/sample/stream/HystrixSampleSseServlet.java
/**
* - maintain an open connection with the client
* - on initial connection send latest data of each requested event type
* - subsequently send all changes for each requested event type
*
* @param request incoming HTTP Request
* @param response outgoing HTTP Response (as a streaming response)
* @throws javax.servlet.ServletException
* @throws java.io.IOException
*/
private void handleRequest(HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
final AtomicBoolean moreDataWillBeSent = new AtomicBoolean(true);
Subscription sampleSubscription = null;
/* ensure we aren't allowing more connections than we want */
int numberConnections = incrementAndGetCurrentConcurrentConnections();
try {
int maxNumberConnectionsAllowed = getMaxNumberConcurrentConnectionsAllowed(); //may change at runtime, so look this up for each request
if (numberConnections > maxNumberConnectionsAllowed) {
response.sendError(503, "MaxConcurrentConnections reached: " + maxNumberConnectionsAllowed);
} else {
/* initialize response */
response.setHeader("Content-Type", "text/event-stream;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
response.setHeader("Pragma", "no-cache");
final PrintWriter writer = response.getWriter();
//since the sample stream is based on Observable.interval, events will get published on an RxComputation thread
//since writing to the servlet response is blocking, use the Rx IO thread for the write that occurs in the onNext
sampleSubscription = sampleStream
.observeOn(Schedulers.io())
.subscribe(new Subscriber<String>() {
@Override
public void onCompleted() {
logger.error("HystrixSampleSseServlet: ({}) received unexpected OnCompleted from sample stream", getClass().getSimpleName());
moreDataWillBeSent.set(false);
}
@Override
public void onError(Throwable e) {
moreDataWillBeSent.set(false);
}
@Override
public void onNext(String sampleDataAsString) {
if (sampleDataAsString != null) {
try {
writer.print("data: " + sampleDataAsString + "\n\n");
// explicitly check for client disconnect - PrintWriter does not throw exceptions
if (writer.checkError()) {
throw new IOException("io error");
}
writer.flush();
} catch (IOException ioe) {
moreDataWillBeSent.set(false);
}
}
}
});
while (moreDataWillBeSent.get() && !isDestroyed) {
try {
Thread.sleep(pausePollerThreadDelayInMs);
} catch (InterruptedException e) {
moreDataWillBeSent.set(false);
}
}
}
} finally {
decrementCurrentConcurrentConnections();
if (sampleSubscription != null && !sampleSubscription.isUnsubscribed()) {
sampleSubscription.unsubscribe();
}
}
}
##报错2
10:45:53.194 INFO [http-nio-9002-exec-393] Caller+0 at org.springframework.cloud.netflix.hystrix.dashboard.HystrixDashboardConfiguration$ProxyStreamServlet.doGet(HystrixDashboardConfiguration.java:165)
-
Proxy opening connection to: http://localhost:9002/hystrix.stream
2017-03-28 10:45:53.209 WARN 1404 --- [o-9002-exec-393] ashboardConfiguration$ProxyStreamServlet : Failed opening connection to http://localhost:9002/hystrix.stream : 503 : HTTP/1.1 503
10:45:53.209 WARN [http-nio-9002-exec-393] Caller+0 at org.springframework.cloud.netflix.hystrix.dashboard.HystrixDashboardConfiguration$ProxyStreamServlet.doGet(HystrixDashboardConfiguration.java:212)
- Failed opening connection to http://localhost:9002/hystrix.stream : 503 : HTTP/1.1 503
2017-03-28 10:45:53.209 WARN 1404 --- [o-9002-exec-391] ashboardConfiguration$ProxyStreamServlet : Failed opening connection to http://localhost:9002/hystrix.stream : 503 : HTTP/1.1 503
10:45:53.209 WARN [http-nio-9002-exec-391] Caller+0 at org.springframework.cloud.netflix.hystrix.dashboard.HystrixDashboardConfiguration$ProxyStreamServlet.doGet(HystrixDashboardConfiguration.java:212)
- Failed opening connection to http://localhost:9002/hystrix.stream : 503 : HTTP/1.1 503
curl一下
➜ ~ curl -i http://localhost:9002/hystrix.stream
HTTP/1.1 503
X-Application-Context: recommend:9002
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Tue, 28 Mar 2017 02:48:23 GMT
Connection: close
{"timestamp":1490669303758,"status":503,"error":"Service Unavailable","message":"MaxConcurrentConnections reached: 20","path":"/hystrix.stream"}%
如果出现请求/hystrix.stream一直阻塞,或者报错Unable to connect to Command Metric Stream,表示你没有配置HystrixCommand。
解决方案
hystrix.config.stream.maxConcurrentConnections: 50
搭建turbine时 hystrix MaxConcurrentConnections reached 异常的更多相关文章
- 搭建Turbine时,报错误:Property or field 'default' cannot be found on object of type 'com.netflix.appinfo.InstanceInfo'
Spring Boot + Eureka Server + Hystrix with Turbine: empty turbine.stream 配置的时候遇到了问题: Property or fie ...
- Visual Studio2012打开时弹出“遇到异常:这可能是由某个扩展导致的”错误的解决办法
Visual Studio2012打开时弹出"遇到异常:这可能是由某个扩展导致的"错误的解决办法: 具体问题如下: 分析原因:网上搜集了以下,出现异常的原因是安装了第三方控件,然后 ...
- 用T-SQL命令附加数据库时,出现如下异常信息
用T-SQL命令附加数据库时,出现如下异常信息: 无法打开物理文件 XXX.mdf".操作系统错误 5:"5(拒绝访问.)". (Microsoft SQL Server ...
- 搭建ReactNative时的最普遍的错误—— ":CFBundleIdentifier", Does Not Exist
报错 ":CFBundleIdentifier", Does Not Exist 今天搭建Reactnative 报错 注意当你第一次搭建RN时,包体下载的都是最新的版本,由于现在 ...
- Java数组超出范围时如何处理多个异常?
在Java编程中,数组超出范围时如何处理多个异常? 此示例显示如何使用System类的System.err.println()方法处理多个异常方法. package com.yiibai; publi ...
- 开启turbine收集hystrix指标功能
使用turbine收集hystrix指标 1.pom中引入对turbin的依赖,并增加dashboard图形界面的展示 <dependencies> <dependency> ...
- C#连接solr时提示 java内存异常 (jetty和tomcat哪个更High) java.lang.OutOfMemoryError
C#连接solr时提示 java内存异常 java.lang.OutOfMemoryError 时间:20180130 09:51:13.329,消息:异常消息<?xml version=& ...
- 手把手搭建一套基于 Sentry 的异常监控系统
手把手搭建一套基于 Sentry 的异常监控系统 Sentry 开源版 DevOps refs https://github.com/getsentry/sentry sentry-anomaly-m ...
- 在centOS环境搭建airtest时遇到 Xlib.error.DisplayNameError: Bad display name "" 和Xlib.error.XauthError异常
现在的问题 (airtestVenv) [root@67 airtest_selenium]# python3 proxy.pyTraceback (most recent call last): ...
随机推荐
- SpringCloud初体验:七、gateway 网关服务如何做token验证
说说背景:假如有一个用户服在用户登录后,生成一个token给到客户端,用户每次请求时都需要这个token,于是每次都会在网关 gateway 校验,校验通过后网关从token中解析出userId,然后 ...
- Windows网络编程经验小结
转自:CSDN网友的强贴,其ID:gdy119 (夜风微凉) 1. 如果在已经处于 ESTABLISHED状态下的socket(一般由端口号和标志符区分)调用closesocket(一般不会立即关闭而 ...
- O(n)空间复杂度,打印杨辉三角形的前n行
做小米的笔试题,给出一个整数n,求出它在杨辉三角形中第一次出现的行号. 想了半天,只能暴力法,从第1行开始找,一直找到第n行,若找得到则返回行号,若找不到则返回n+1(因为第n+1行第2列肯定是n). ...
- BASIC-6_蓝桥杯_杨辉三角形
示例代码: #include <stdio.h>#include <stdlib.h> int main(void){ int n = 0 ; int i = 0 , j = ...
- 【Spring学习笔记-MVC-1.3】消息转换器HttpMessageConverter
作者:ssslinppp 参考链接: SpringMVC源码剖析(五)-消息转换器HttpMessageConverter: http://my.oschina.net/lichhao/b ...
- jsoncpp 构造空数组
因为要构造类似如下的 {"FurnitureItemObject":[],"FurniturePlaceItemObject":[],"RoomNum ...
- InfluxDB 备份和恢复
InfluxDB操作 . 显示数据库 > show databases > create database test > drop database test . 显示说有表 > ...
- 搭建OpenStack先电云平台
实际操作示意图 在VMware里面创建两台centos7的虚拟机作为搭建云平台的两节点配置如下: 1.第一台虚拟机 作为控制节点 2CPU 3G以上内存 硬盘50G 网络适配器一个nat 一个仅主 ...
- [UE4]安卓打包成一个apk
勾上就可以了
- [UE4]Visual Studio的相关插件安装:UE4.natvis和UnrealVS Extension
转自:http://aigo.iteye.com/blog/2281182 UE4.natvis 官方文档: https://docs.unrealengine.com/latest/INT/Prog ...