Java 假客户端拒绝连接
Connection refused from Java feign client
我有一个我正在使用的微服务之一的模拟器。我的微服务和模拟器都部署在本地主机上,我可以从 curl 调用模拟器,但是当它从 Java Feign 客户端调用时,我收到 connection Refused from the Feign client 。
1)我已经检查过模拟器已经启动并且 运行 在端口
上
netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:http-alt 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:19090 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:19091 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:19092 0.0.0.0:* LISTEN
2) 我可以从 Curl 调用模拟器
curl -v -X GET -H "X-B3-ParentSpanId:9b9c585fae4b6909" -H "X-B3-Sampled:1" -H "X-B3-TraceId:897aa305e5cd4a0e9b9c585fae4b6909" http://127.0.0.1:19092/restservices/oda/v1/flow/partner/BBY/reference/29920299209700018540
Note: Unnecessary use of -X or --request, GET is already inferred.
* Trying 127.0.0.1...
* TCP_NODELAY set
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to 127.0.0.1 (127.0.0.1) port 19092 (#0)
> GET /restservices/oda/v1/flow/partner/BBY/reference/29920299209700018540 HTTP/1.1
> Host: 127.0.0.1:19092
> User-Agent: curl/7.59.0
> Accept: */*
> X-B3-ParentSpanId:9b9c585fae4b6909
> X-B3-Sampled:1
> X-B3-TraceId:897aa305e5cd4a0e9b9c585fae4b6909
>
{"cart":{"iccid":{"state":"xSEpJXbZHTieuwbEmkyw"},"imei":{"state":"qZqSNjyCRDcGtcNkkPuT"},"offer":{"state":"HepwvfrskMqCaIixZqdQ"},"phone":{"state":"IFjenviIgYSIxbTvxqgw"},"state":"TLNwJRHopqpUfIgpCOsL"},"customer":{"contactPhone":"LOfsPamSdUOAmBnGWHJU","customerId":"kwotSWtOKNCRcZTGwMWS","securityInfo":{"state":"cdQVsEhmmjdfacuptAdx"},"state":"uzjaUvZfUlwzlKBaKyri"},"id":"29920299209700018540","order":{" ":{"state":"ZorISJYWfCnCFDjwynQS"},"orderSubmit":{"state":"wxViwjAXJaKVbPlFjVCS"},"state":"mumvrXaOLqxYlobjWbDb"},"partnerReference":{"partnerId":"uklHdntzuiqVMDNkZTnm","referenceId":"UwXVOptxnakWMYdVaQrb"},"state":"elMbDlvjURDTlzvwddiO","validFor":{"endDateTime":"2018-03-08T23:27:56.213Z","startDateTime":"2017-12-08T23:27:56.213Z"}}< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json
< Content-Length: 769
< Date: Tue, 25 Sep 2018 07:07:54 GMT
<
{ [769 bytes data]
但是当它通过 Feign 客户端从我的微服务调用时,它给我连接拒绝错误
"label" : "feign.RetryableException: Connect to [localhost/127.0.0.1] failed: Connection refused executing GET http://127.0.0.1:19092/restservices/oda/v1/flow/partner/BBY/reference/29920299209700018540"
我解决了这个问题
原来有两个相同的远程服务
其中一个没有启动成功
所以我拒绝重复服务
希望这能解决你的问题
我有一个我正在使用的微服务之一的模拟器。我的微服务和模拟器都部署在本地主机上,我可以从 curl 调用模拟器,但是当它从 Java Feign 客户端调用时,我收到 connection Refused from the Feign client 。 1)我已经检查过模拟器已经启动并且 运行 在端口
上netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:http-alt 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:19090 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:19091 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:19092 0.0.0.0:* LISTEN
2) 我可以从 Curl 调用模拟器
curl -v -X GET -H "X-B3-ParentSpanId:9b9c585fae4b6909" -H "X-B3-Sampled:1" -H "X-B3-TraceId:897aa305e5cd4a0e9b9c585fae4b6909" http://127.0.0.1:19092/restservices/oda/v1/flow/partner/BBY/reference/29920299209700018540
Note: Unnecessary use of -X or --request, GET is already inferred.
* Trying 127.0.0.1...
* TCP_NODELAY set
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to 127.0.0.1 (127.0.0.1) port 19092 (#0)
> GET /restservices/oda/v1/flow/partner/BBY/reference/29920299209700018540 HTTP/1.1
> Host: 127.0.0.1:19092
> User-Agent: curl/7.59.0
> Accept: */*
> X-B3-ParentSpanId:9b9c585fae4b6909
> X-B3-Sampled:1
> X-B3-TraceId:897aa305e5cd4a0e9b9c585fae4b6909
>
{"cart":{"iccid":{"state":"xSEpJXbZHTieuwbEmkyw"},"imei":{"state":"qZqSNjyCRDcGtcNkkPuT"},"offer":{"state":"HepwvfrskMqCaIixZqdQ"},"phone":{"state":"IFjenviIgYSIxbTvxqgw"},"state":"TLNwJRHopqpUfIgpCOsL"},"customer":{"contactPhone":"LOfsPamSdUOAmBnGWHJU","customerId":"kwotSWtOKNCRcZTGwMWS","securityInfo":{"state":"cdQVsEhmmjdfacuptAdx"},"state":"uzjaUvZfUlwzlKBaKyri"},"id":"29920299209700018540","order":{" ":{"state":"ZorISJYWfCnCFDjwynQS"},"orderSubmit":{"state":"wxViwjAXJaKVbPlFjVCS"},"state":"mumvrXaOLqxYlobjWbDb"},"partnerReference":{"partnerId":"uklHdntzuiqVMDNkZTnm","referenceId":"UwXVOptxnakWMYdVaQrb"},"state":"elMbDlvjURDTlzvwddiO","validFor":{"endDateTime":"2018-03-08T23:27:56.213Z","startDateTime":"2017-12-08T23:27:56.213Z"}}< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json
< Content-Length: 769
< Date: Tue, 25 Sep 2018 07:07:54 GMT
<
{ [769 bytes data]
但是当它通过 Feign 客户端从我的微服务调用时,它给我连接拒绝错误
"label" : "feign.RetryableException: Connect to [localhost/127.0.0.1] failed: Connection refused executing GET http://127.0.0.1:19092/restservices/oda/v1/flow/partner/BBY/reference/29920299209700018540"
我解决了这个问题
原来有两个相同的远程服务
其中一个没有启动成功
所以我拒绝重复服务
希望这能解决你的问题