Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout causes error #547

Open
dhakehurst opened this issue Jun 3, 2024 · 2 comments
Open

Timeout causes error #547

dhakehurst opened this issue Jun 3, 2024 · 2 comments

Comments

@dhakehurst
Copy link

I'm using version 5.1.1.Final

I find that if I set 'timeouts' the second of the requests in the following code fails.
I cannot see why ?
With no timeout (which defaults to -1) it works fine,
except on the occasion that the server does not respond - hence I want to use a timeout.

However, adding the timeout(s), of any value, causes a socket read-timeout on the second request ('query.submit')

javax.ws.rs.ProcessingException: java.net.SocketTimeoutException: Read timed out
	at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:531)
	at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:300)
	at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$0(JerseyInvocation.java:662)
...
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.base/sun.nio.ch.NioSocketImpl.timedRead(NioSocketImpl.java:278)
	at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:304)
// Use HttpClient instead of the default HttpUrlConnection
final ClientConfig clientConfig = new ClientConfig().connectorProvider(new ApacheConnectorProvider());

// Fixes Invalid cookie header: ... Invalid 'expires' attribute: Thu, 01 Dec 1994 16:00:00 GMT
final var reqCfg = RequestConfig.custom() //
			.setCookieSpec(CookieSpecs.STANDARD) //
			.setConnectionRequestTimeout(timeout_ms.orElse(-1)) //
			.setConnectTimeout(timeout_ms.orElse(-1)) //
			.setSocketTimeout(timeout_ms.orElse(-1)) //
			.build();
clientConfig.property(ApacheClientProperties.REQUEST_CONFIG, reqCfg);
clientConfig.register(MultiPartFeature.class);

final ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder.withConfig(clientConfig);
// IBM jazz-apps use JEE Form based authentication
clientBuilder.register(new JEEFormAuthenticator(baseUrl.toString(), userName, password));
final var oslcClient = new OslcClient(clientBuilder);

final var rootServicesUri = baseUrl + "/rootservices";
final Response response = oslcClient.getResource(rootServicesUri.toString(), OSLCConstants.CT_RDF);
final InputStream is = response.readEntity(InputStream.class);
final var rootServices = ModelFactory.createDefaultModel();
rootServices.read(is, rootServicesUri.toString());
final Property prop = rootServices.createProperty(OSLCConstants.OSLC_RM, RootServicesConstants.RM_ROOTSERVICES_CATALOG_PROP);
final Statement stmt = rootServices.getProperty((Resource) null, prop);
final var rmServiceCatalogUrl = stmt.getObject().toString();

final String serviceProviderUrl = oslcClient.lookupServiceProviderUrl(rmServiceCatalogUrl, projectName);
final String queryCapabilityUrl = oslcClient.lookupQueryCapability(serviceProviderUrl, OSLCConstants.OSLC_RM_V2, OSLCConstants.RM_REQUIREMENT_TYPE);
final OslcQueryParameters queryParams = new OslcQueryParameters();
queryParams.setSelect("*");
final OslcQuery query = new OslcQuery(oslcClient, queryCapabilityUrl, queryParams);

final OslcQueryResult result = query.submit();
System.out.println(result.getRawResponse().readEntity(String.class));
@berezovskyi
Copy link
Contributor

@Jad-el-khoury have you encountered something similar?

@Jad-el-khoury
Copy link
Contributor

Does not look familiar to me, no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants