小编Tin*_*ter的帖子

Angular 2 http没有捕获连接拒绝错误

我想捕获所有http错误,以通知用户发生的问题.

所以,我创建了一个使用catch执行http get的方法.

get(path: string): Promise<any> {
  let headers = new Headers();
  return this.http.get(path, { headers: headers })
    .toPromise()
    .then(response => { ... })
    .catch((response: Response) => { this.errorHandler(response); });
}
Run Code Online (Sandbox Code Playgroud)

当path参数为'/ fault-url'时,catch按预期处理.

但是当路径为' http:// localhost:5000/fault-url '时,catch方法不会捕获错误.我已经将日志记录添加到所有不同的地方,但它接收get方法只是中止.控制台日志显示以下错误

选项http:// localhost:5000/fault-url net :: ERR_CONNECTION_REFUSED

EXCEPTION:响应状态:URL为0:null

未捕获的响应{_body:ProgressEvent,status:0,ok:false,statusText:"",headers:Headers ...}

http真的中止还是我做错了什么?

http try-catch typescript angular

5
推荐指数
1
解决办法
2314
查看次数

Docker 容器上的 Wildfly 内的 ActiveMQ 给出:检测到无效的“主机”值“0.0.0.0”

我在 Docker 容器中运行 Wildfly。在 Wildfly 中,messaging-activemq 子系统处于活动状态。子系统和扩展默认值取自standalone-full.xml 文件。

启动wildfly后,显示以下输出

[org.apache.activemq.artemis.jms.server] (ServerService Thread Pool -- 64)
AMQ121005: Invalid "host" value "0.0.0.0" detected for "http-connector" connector.
Switching to "eeb79399d447".
If this new address is incorrect please manually configure the connector to use the proper one.
Run Code Online (Sandbox Code Playgroud)

eeb79399d447 是 docker 容器 ID。我的 java 客户端也无法连接到 jms。连接时出现以下错误。

AMQ214016: Failed to create netty connection: java.net.UnknownHostException: eeb79399d447
Run Code Online (Sandbox Code Playgroud)

当我在本地工作站(docker 外部)上启动 wildfly 时,问题不会发生,我可以连接到 jms 并发送消息。

activemq-classic docker wildfly

5
推荐指数
1
解决办法
2599
查看次数