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 异常的更多相关文章

  1. 搭建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 ...

  2. Visual Studio2012打开时弹出“遇到异常:这可能是由某个扩展导致的”错误的解决办法

    Visual Studio2012打开时弹出"遇到异常:这可能是由某个扩展导致的"错误的解决办法: 具体问题如下: 分析原因:网上搜集了以下,出现异常的原因是安装了第三方控件,然后 ...

  3. 用T-SQL命令附加数据库时,出现如下异常信息

    用T-SQL命令附加数据库时,出现如下异常信息: 无法打开物理文件 XXX.mdf".操作系统错误 5:"5(拒绝访问.)". (Microsoft SQL Server ...

  4. 搭建ReactNative时的最普遍的错误—— ":CFBundleIdentifier", Does Not Exist

    报错 ":CFBundleIdentifier", Does Not Exist 今天搭建Reactnative 报错 注意当你第一次搭建RN时,包体下载的都是最新的版本,由于现在 ...

  5. Java数组超出范围时如何处理多个异常?

    在Java编程中,数组超出范围时如何处理多个异常? 此示例显示如何使用System类的System.err.println()方法处理多个异常方法. package com.yiibai; publi ...

  6. 开启turbine收集hystrix指标功能

    使用turbine收集hystrix指标 1.pom中引入对turbin的依赖,并增加dashboard图形界面的展示 <dependencies> <dependency> ...

  7. C#连接solr时提示 java内存异常 (jetty和tomcat哪个更High) java.lang.OutOfMemoryError

    C#连接solr时提示 java内存异常   java.lang.OutOfMemoryError 时间:20180130 09:51:13.329,消息:异常消息<?xml version=& ...

  8. 手把手搭建一套基于 Sentry 的异常监控系统

    手把手搭建一套基于 Sentry 的异常监控系统 Sentry 开源版 DevOps refs https://github.com/getsentry/sentry sentry-anomaly-m ...

  9. 在centOS环境搭建airtest时遇到 Xlib.error.DisplayNameError: Bad display name "" 和Xlib.error.XauthError异常

    现在的问题 (airtestVenv) [root@67 airtest_selenium]# python3 proxy.pyTraceback (most recent call last):  ...

随机推荐

  1. 后台取IE的相关信息

    HttpBrowserCapabilities b = Request.Browser; Response.Write("浏览器名称和版本号:" + b.Type + " ...

  2. JS给HTML5页面<Select></Select>绑定选中项

    获取选中值: function setApprovalPersonName() { var name = $("#approvalPersion").find("opti ...

  3. Microsoft Dynamics CRM 2011 中 SQL 语句总结

    一.查询用户和团队 插入的类型:OwnerIdType 可以为用户或团队: 1.团队: select top 1 ObjectTypeCode from metadataschema.entity w ...

  4. RedHat Enterprise Linux7.0安装Oracle12c

    1. 验证 1.1 硬盘空间要求 1.1.1 安装盘 类型 占用磁盘空间 Enterprise Edition 6.4GB Standard Edition 6.1GB Standard Editio ...

  5. REST风格框架:从MVC到前后端分离***

    摘要: 本人在前辈<从MVC到前后端分离(REST-个人也认为是目前比较流行和比较好的方式)>一文的基础上,实现了一个基于Spring的符合REST风格的完整Demo,具有MVC分层结构并 ...

  6. BASIC-7_蓝桥杯_特殊的数字

    代码示例: #include <stdio.h>#define B(X) (X)*(X)*(X) int main(void){ int i = 0 ; int a = 0 , b = 0 ...

  7. 网络对抗 Exp0 Kali安装 Week1

    2018-2019 网络对抗 Exp0 Kali安装 Week1 目录 一.下载 二.安装运行 三.配置 四.问题 一.下载 在百度中搜索kali linux 选择并点击Kali Linux | Pe ...

  8. 学习笔记之Cloud computing

    Cloud computing - Wikipedia https://en.wikipedia.org/wiki/Cloud_computing

  9. 字符串拼接和dom回流

    以对象的角度分析  对象的两方面 属性和方法 研究对象,主要是研究对象的属性和方法 案例: <ul id="list"> <li></li> & ...

  10. Hibernate inverse反转

    inverse: inverse: 指定由哪一方来维护之间的关联关系 false默认,表示不放弃,是主动放 true:表示把关联关系的维护反转(放弃),对集合对象的修改不会被反映到数据库中 容易出现的 ...