本文整理了Java中org.eclipse.jetty.client.HttpClient.setTimeout()
方法的一些代码示例,展示了HttpClient.setTimeout()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.setTimeout()
方法的具体详情如下:
包路径:org.eclipse.jetty.client.HttpClient
类名称:HttpClient
方法名:setTimeout
暂无
代码示例来源:origin: 4thline/cling
public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException {
this.configuration = configuration;
log.info("Starting Jetty HttpClient...");
client = new HttpClient();
// Jetty client needs threads for its internal expiration routines, which we don't need but
// can't disable, so let's abuse the request executor service for this
client.setThreadPool(
new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) {
@Override
protected void doStop() throws Exception {
// Do nothing, don't shut down the Cling ExecutorService when Jetty stops!
}
}
);
// These are some safety settings, we should never run into these timeouts as we
// do our own expiration checking
client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000);
client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000);
client.setMaxRetries(configuration.getRequestRetryCount());
try {
client.start();
} catch (Exception ex) {
throw new InitializationException(
"Could not start Jetty HTTP client: " + ex, ex
);
}
}
代码示例来源:origin: kingthy/TVRemoteIME
public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException {
this.configuration = configuration;
log.info("Starting Jetty HttpClient...");
client = new HttpClient();
// Jetty client needs threads for its internal expiration routines, which we don't need but
// can't disable, so let's abuse the request executor service for this
client.setThreadPool(
new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) {
@Override
protected void doStop() throws Exception {
// Do nothing, don't shut down the Cling ExecutorService when Jetty stops!
}
}
);
// These are some safety settings, we should never run into these timeouts as we
// do our own expiration checking
client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000);
client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000);
client.setMaxRetries(configuration.getRequestRetryCount());
try {
client.start();
} catch (Exception ex) {
throw new InitializationException(
"Could not start Jetty HTTP client: " + ex, ex
);
}
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
/**
* @deprecated use {@link #setTimeout(long)} instead.
* @param timeout the period in ms that an exchange will wait for a response from the server.
*/
@Deprecated
public void setSoTimeout(int timeout)
{
setTimeout(timeout);
}
代码示例来源:origin: org.apache.camel/camel-jetty8
@Override
public void setTimeout(long timeout) {
client.setTimeout(timeout);
ce.setTimeout(timeout);
}
代码示例来源:origin: org.openhab.binding/org.openhab.binding.fritzaha
asyncclient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
asyncclient.setMaxConnectionsPerAddress(asyncmaxconns);
asyncclient.setTimeout(asynctimeout);
try {
asyncclient.start();
代码示例来源:origin: jdye64/nifi-addons
httpClient.setTimeout(TIMEOUT);
httpClient.start();
代码示例来源:origin: apache/incubator-unomi
private BayeuxClient makeClient() throws Exception {
HttpClient httpClient = new HttpClient();
httpClient.setConnectTimeout(CONNECTION_TIMEOUT);
httpClient.setTimeout(READ_TIMEOUT);
httpClient.start();
if (sfdcSession == null) {
logger.error("Invalid session !");
return null;
}
logger.info("Login successful!\nServer URL: " + sfdcSession.getEndPoint()
+ "\nSession ID=" + sfdcSession.getSessionId());
Map<String, Object> options = new HashMap<String, Object>();
options.put(ClientTransport.TIMEOUT_OPTION, READ_TIMEOUT);
LongPollingTransport transport = new LongPollingTransport(
options, httpClient) {
@Override
protected void customize(ContentExchange exchange) {
super.customize(exchange);
exchange.addRequestHeader("Authorization", "OAuth " + sfdcSession.getSessionId());
}
};
BayeuxClient client = new BayeuxClient(getSalesforceStreamingEndpoint(
sfdcSession.getEndPoint()), transport);
return client;
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
client.setTimeout(Long.parseLong(t));
代码示例来源:origin: org.sonatype.nexus/nexus-indexer
httpClient.setTimeout( connectionTimeoutMs );
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
_client.setTimeout(Long.parseLong(_timeout));
代码示例来源:origin: org.fourthline.cling/cling-core
public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException {
this.configuration = configuration;
log.info("Starting Jetty HttpClient...");
client = new HttpClient();
// Jetty client needs threads for its internal expiration routines, which we don't need but
// can't disable, so let's abuse the request executor service for this
client.setThreadPool(
new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) {
@Override
protected void doStop() throws Exception {
// Do nothing, don't shut down the Cling ExecutorService when Jetty stops!
}
}
);
// These are some safety settings, we should never run into these timeouts as we
// do our own expiration checking
client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000);
client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000);
client.setMaxRetries(configuration.getRequestRetryCount());
try {
client.start();
} catch (Exception ex) {
throw new InitializationException(
"Could not start Jetty HTTP client: " + ex, ex
);
}
}
代码示例来源:origin: org.apache.servicemix/servicemix-http
public org.eclipse.jetty.client.HttpClient createNewJettyClient() throws Exception {
org.eclipse.jetty.client.HttpClient tempClient = new org.eclipse.jetty.client.HttpClient();
QueuedThreadPool btp = new QueuedThreadPool();
btp.setMaxThreads(getConfiguration().getJettyClientThreadPoolSize());
tempClient.setThreadPool(btp);
tempClient.setConnectorType(org.eclipse.jetty.client.HttpClient.CONNECTOR_SELECT_CHANNEL);
tempClient.setTimeout(getConfiguration().getProviderExpirationTime());
tempClient.setConnectTimeout(getConfiguration().getClientConnectTimeout());
tempClient.setMaxConnectionsPerAddress(getConfiguration().getMaxConnectionsPerAddress());
tempClient.start();
return tempClient;
}
代码示例来源:origin: net.anthavio/hatatitla
public HttpClient buildHttpClient() {
HttpClient client = new HttpClient();
//client.setConnectBlocking(false);
client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
client.setConnectTimeout(getConnectTimeoutMillis());
client.setTimeout(getReadTimeoutMillis());
client.setMaxConnectionsPerAddress(getPoolMaximumSize());
client.setThreadPool(new QueuedThreadPool(getPoolMaximumSize()));
//client.setIdleTimeout(config.get???);
if (getFollowRedirects()) {
client.setMaxRedirects(10);
}
if (getAuthentication() != null) {
Realm realm = new SimpleRealm("whatever", getAuthentication().getUsername(), getAuthentication().getPassword());
client.setRealmResolver(new SimpleRealmResolver(realm));
}
return client;
}
代码示例来源:origin: org.apache.servicemix/servicemix-http
jettyClient.setTimeout(getProviderExpirationTime());
jettyClient.setMaxConnectionsPerAddress(getMaxConnectionsPerAddress());
if (principal != null && credentials != null) {
内容来源于网络,如有侵权,请联系作者删除!