Java feign客户端拒绝连接

时间:2018-09-25 07:21:35

标签: java spring-boot networking microservices feign

我有一个用于我正在使用的微服务的模拟器。我的微服务和模拟器都部署在本地主机上,我可以从curl调用模拟器,但是当从Java Feign客户端调用模拟器时,我会从Feign客户端拒绝连接。 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"

1 个答案:

答案 0 :(得分:1)

我解决了这个问题
原来有两个相同的远程服务
其中一个没有成功
所以我拒绝了重复的服务
希望这能解决您的问题