搭建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): ...
随机推荐
- redis-benchmark压力测试
redis-benchmark是redis官方提供的压测工具,安装好redis后,默认安装.使用简便. 语法: Usage: redis-benchmark [-h <host>] [-p ...
- mysql四种修改密码的方式
方法1: 用SET PASSWORD命令 首先登录MySQL. 格式:mysql> set password for 用户名@localhost = password('新密码'); 例子:my ...
- ActiveMQ生产者和消费者优化策略
一.生产者优化策略 默认情况下,ActiveMQ服务端认为生产者端发送的是PERSISTENT Message.所以如果要发送NON_PERSISTENT Message,那么生产者端就要明确指定. ...
- 使用Apriori进行关联分析(一)
大型超市有海量交易数据,我们可以通过聚类算法寻找购买相似物品的人群,从而为特定人群提供更具个性化的服务.但是对于超市来讲,更有价值的是如何找出商品的隐藏关联,从而打包促销,以增加营业收入.其中最经典的 ...
- git 知识点
git 删除远程已经推送过的文件或者文件夹 git rm -r --cached [文件或文件夹] git status git add . git commit -m '删除远程仓库文件,本地仓库和 ...
- netty SimpleChannelInboundHandler<Message>和ChannelInboundHandlerApter
一个兄弟的测试体验:https://blog.csdn.net/linuu/article/details/51307060 比较官方:https://www.imooc.com/article/28 ...
- 无人驾驶之激光雷达&摄像头(主要from 速腾CEO 邱纯鑫分享)
无人驾驶之激光雷达&摄像头 (from 速腾CEO 邱纯鑫公开课分享) 根据听的一些讲座和看的书籍,个人感觉:目前现在的自动驾驶,根本问题还是在于感知(路况,周边物体,交通标识等等),控制的方 ...
- 小峰servlet/jsp(7)jstl国际化标签库、sql标签库等
一.jstl国际化标签库: fmt:setLocale 设定用户所在的区域: fmt:formatDate 对日期进行格式化 fmt:requestEncoding 设置所有的请求编码; fmt: ...
- java study3
面向过程与面向对象 面向过程:必须了解整个过程,每个步骤互成因果关系,每个因果关系都构成一个步骤,多个步骤就构成了一个系统.因为存在因果关系,每隔步骤难以分离,非常紧密,当任何一步出现问题,将会影响到 ...
- matplot 代码实例
matplot 代码实例 #!/usr/bin/env python # coding=utf-8 import numpy as np import matplotlib.pyplot as plt ...