Restlet超时 [英] Restlet timeout

查看:111
本文介绍了Restlet超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改 Restlet客户端 get()的超时?

我所能找到的只是过时的SetConnectTimeout().我尝试context.getParameters().add ( "socketTimeout", "1000" );失败.

All I've have been able to find is the obsolete SetConnectTimeout(). I tried context.getParameters().add ( "socketTimeout", "1000" ); with no success.

推荐答案

基本上,这是通过配置客户端连接器(类org.restlet.Client)来完成的:

Basically, this is done by configuring the client connector (class org.restlet.Client):

client.context.getParameters().add ( "parameter", "value" );

我看到了两个不同的上下文,因此看到了两种获取客户端连接器的方式.

I see two distinct contexts and thus two ways to get the client connector.

  1. 您正在org.restlet.Component容器内运行客户端调用 在这种情况下,请配置该组件托管的公共客户端连接器:

  1. You are running your client calls inside a org.restlet.Component container In this case, configure the common client connector hosted by the component:

Component c = new Component();
Client client = c.getClients().add(Protocol.HTTP);
client.getContext().getParameters().add ( "parameter", "value" );

  • 您没有在org.restlet.Component容器内运行客户端调用 在这种情况下,请手动实例化客户端连接器并将其设置为ClientResource

  • You are not running your client calls inside a org.restlet.Component container In this case, instantiate manually the client connector and set it to the ClientResource

    Client client = new Client(new Context(), Protocol.HTTP);
    client.getContext().getParameters().add ( "parameter", "value" );
    
    ClientResource cr = new ClientResource("http://example.com");
    cr.setNext(client);
    

  • 最后,要设置的可用参数列表取决于您使用的客户端连接器的类型(内部连接器,基于httpclient等) 您可以查看此页面 http://restlet.com/learn/指南/2.2/core/base/connectors/.

    To conclude with, the list of available parameters to be set depends on the kind of client connector you are using (internal connector, based on httpclient, etc) You can have a look at this page http://restlet.com/learn/guide/2.2/core/base/connectors/.

    这篇关于Restlet超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆