Hi all:

    I use httpclient (v4.3.6) to visit kylin restful api and the java code is 
as follows:


        private static CloseableHttpClient httpClient = null;


        private static CloseableHttpClient getHttpClient(String 
authenticationURL, String authenticationToken) {
                if (httpClient == null) {
                        httpClient = HttpClients.createDefault();
                        HttpPost post = new HttpPost(authenticationURL);
                        post.addHeader("Content-Type", 
"application/json;charset=UTF-8");
                        post.addHeader("Authorization", authenticationToken);
                        post.addHeader("Accept", "*/*");
                        try {
                                HttpResponse res = httpClient.execute(post);
                                
System.out.println(EntityUtils.toString(res.getEntity()));
                        } catch (Exception e) {
                                e.printStackTrace();
                        }
                }
                return httpClient;
        }



        public static String sendHttpGet(String url, String authenticationURL, 
String authenticationToken) throws ClientProtocolException, IOException {
                HttpGet get = new HttpGet(url);
                HttpResponse response = getHttpClient(authenticationURL, 
authenticationToken).execute(get);
                return EntityUtils.toString(response.getEntity());
        }



    Well, when I getting the httpClient for the first time, httpClient == null 
and the code  above can create a newly httpClient which can work well.


    However, if a timed task(e.g. 1hour per running) call the getHttpClient() 
function using the same httpClient 1 hour later after the first calling, the 
session expired and it returns 401.


    So, I want to know how long does one session of kylin api keep, and how can 
I solve the problem. Looking forward to your reply, thx~~




------------------
?????? | CVTE
cor...@foxmail.com
????????????????????????????
Guangzhou Shiyuan Electronics Co., Ltd.

Reply via email to