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. 测试开发系列之Python开发mock接口(一)

    什么是mock接口呢,举个栗子,你在一家电商公司,有查看商品.购物.支付.发 货.收获等等等一大堆功能,你是一个测试人员,测测测,测到支付功能的时候,你就要调用第三方支付接口了,真实支付,直接扣你支付 ...

  2. Windows平台下的线程同步

    引子: 这几天在写一个windows phone平台上的service,由于Windows phone 的内核是基于Windows NT的,这也意味着写Windows Phone的Service代码与 ...

  3. JavaScript模块化-RequireJs实现AMD规范的简单例子

    AMD规范简介 AMD(异步模块定义),是实现JavaScript模块化规范之一,它采用异步方式加载模块,模块的加载不影响后面语句的运行.require.js和curl.js都是实现AMD规范的优秀加 ...

  4. css-inline-block和float的布局二者择其一?

    几个月前,带着不甘和忐忑毅然决然的在亚马逊离职了,当时不知道对我来说是好是坏,现在看来,当初的选择还是蛮不错的.感觉在亚马逊的几个月貌似接触最多的就是wiki和tt了,怀着对技术热忱离开,拒绝了腾讯, ...

  5. java对含有中文的字符串进行Unicode编码

    public class MyUtil { public static void main(String[] args) throws Exception { String s = "a中a ...

  6. [转]Java.APK 反编译

    本文转自:http://blog.csdn.net/vipzjyno1/article/details/21039349/ (注:反编译不是让各位开发者去对一个应用破解搞重装什么的,主要目的是为了促进 ...

  7. ubuntu 常用命令集锦

    一.文件/文件夹管理 ls 列出当前目录文件(不包括隐含文件) ls -a 列出当前目录文件(包括隐含文件) ls -l 列出当前目录下文件的详细信息 cd .. 回当前目录的上一级目录 cd - 回 ...

  8. [UE4]添加蒙太奇动画

    选择蒙太奇所使用的骨骼

  9. VS Code 基本介绍 和 快捷键

    简介 VSCode是微软推出的一款轻量编辑器,采取了和VS相同的UI界面,搭配合适的插件可以大幅提升前端开发的效率. 布局:左侧是用于展示所要编辑的所有文件和文件夹的文件管理器,依次是:资源管理器,搜 ...

  10. onmouseenter和onmouseleave的兼容性问题

    <div onmouseenter="displayMyCon($(this))" onmouseleave="hideMyCon(event,$(this))&q ...