java rest client在连接到kubernetes minikube服务时获得远程关闭错误

时间:2017-08-04 23:28:26

标签: java rest jersey kubernetes minikube

我正在开发一个将在Kubernetes中运行的服务。对于此服务的功能测试,我们的测试会将服务部署到笔记本电脑上运行的minikube上。

在最基本的测试中,java客户端只是ping了服务的运行状况检查端点。 java客户端使用Jersey并创建客户端,如:

    select 2083 as ID  , cast('2016-04-20' as date) as [Date], 1 as myVar  into #temp1

    insert into #temp1
    select 2083   , '2015-03-19',      1

    insert into #temp1
    select 2083,    '2015-01-20'      ,0

    insert into #temp1
    select 2083    ,'2014-12-15'      ,1

    insert into #temp1
    select 2083    ,'2014-11-10'      ,1

    insert into #temp1
    select 2083    ,'2014-10-22'      ,1

    insert into #temp1
    select 2083    ,'2014-10-07'      ,1

    insert into #temp1
    select 2083    ,'2014-09-11'      ,0


    select t.ID, DATE, myvar,
       isnull((case when myvar > 0 then row_number() over (partition by grp order by date)
        end)-1,0)  as newval
from (select t.*, sum(1 - myvar) over (order by date) as grp
      from #temp1 t
     ) t;

但我可以直接在curl或Postman中调用在minikube中运行的相同端点。

从3个不同客户端发送的请求基本相同(用户代理除外):

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
..
 private static final Client CLIENT = ClientBuilder.newClient();

The request fails with;
2017-08-04 13:57:55.202 WARNING [PingTest] Remotely closed
2017-08-04 13:57:55.206 INFO [system.err] javax.ws.rs.ProcessingException: Remotely closed
2017-08-04 13:57:55.207 INFO [system.err]     at org.glassfish.jersey.grizzly.connector.GrizzlyConnector.apply(GrizzlyConnector.java:260)
2017-08-04 13:57:55.207 INFO [system.err]     at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:252)
2017-08-04 13:57:55.208 INFO [system.err]     at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:684)
..

为什么我可以从curl或Postman而不是从Java客户端访问端点的任何想法?

1 个答案:

答案 0 :(得分:0)

原来是一个计时问题,有一个回调方法,意味着在调用服务端点之前等待容器达到就绪状态,但找到绕过回调的代码路径。