You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kylin.apache.org by 李寅威 <25...@qq.com> on 2016/07/11 03:23:56 UTC
How long does one session of kylin api keep
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
coridc@foxmail.com
广州视源电子科技股份有限公司
Guangzhou Shiyuan Electronics Co., Ltd.
Re: How long does one session of kylin api keep
Posted by Jian Zhong <zh...@apache.org>.
Hi yinwei,
you can give a try to set session-config in web.xml
<session-config>
<session-timeout>30</session-timeout>
</session-config>
On Mon, Jul 11, 2016 at 11:23 AM, 李寅威 <25...@qq.com> wrote:
> 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
> coridc@foxmail.com
> 广州视源电子科技股份有限公司
> Guangzhou Shiyuan Electronics Co., Ltd.