<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic java.net.SocketTimeoutException: timeout while calling a REST API in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/java-net-sockettimeoutexception-timeout-while-calling-a-rest-api/m-p/140236#M37490</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I created a batch to get information about sites, persons and documents.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The rest API called is :&amp;nbsp;&lt;A href="http://localhost:8080/alfresco/api/-default-/public/search/versions/1/search" target="_blank" rel="noopener nofollow noreferrer"&gt;/alfresco/api/-default-/public/search/versions/1/search&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;The user calling the webservice is &lt;STRONG&gt;admin&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;The query passed in the body is in &lt;STRONG&gt;afts&lt;/STRONG&gt; language.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I used the&amp;nbsp;&lt;A href="https://github.com/Alfresco/alfresco-client-sdk" target="_blank" rel="noopener nofollow noreferrer"&gt;alfresco-client-sdk&lt;/A&gt; project to call the webservices and search for information.&amp;nbsp;&lt;BR /&gt;The project is documented in &lt;A href="https://hub.alfresco.com/t5/alfresco-content-services-blog/alfresco-java-client-sdk-usage-part-9-queries-search/ba-p/292657" target="_blank" rel="noopener nofollow noreferrer"&gt;this blog&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Everything works well on my machine. But, when I deploy it on the PROD which a unix envirement (ubuntu), A&amp;nbsp;&lt;STRONG&gt;java.net.SocketTimeoutException&lt;/STRONG&gt; was thrown &lt;U&gt;after calling the webservice more than 20 times&lt;/U&gt; (but with different afts queries).&lt;BR /&gt;&lt;BR /&gt;The error message is the following.&lt;/P&gt;&lt;PRE&gt;Caused by: java.net.SocketTimeoutException: timeout
	at okio.Okio$3.newTimeoutException(Okio.java:210)
	at okio.AsyncTimeout.exit(AsyncTimeout.java:288)
	at okio.AsyncTimeout$2.read(AsyncTimeout.java:242)
	at okio.RealBufferedSource.indexOf(RealBufferedSource.java:325)
	at okio.RealBufferedSource.indexOf(RealBufferedSource.java:314)
	at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:210)
	at okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:186)
	at okhttp3.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127)
	at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:53)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:145)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at com.alfresco.client.AbstractClient$BasicAuthInterceptor.intercept(AbstractClient.java:254)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
	at okhttp3.RealCall.execute(RealCall.java:60)
	at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
	at com.custom.service.PeopleService.listSitePeopleByRole(PeopleService.java:84)
	at com.custom.batch.query.PersonQuery$PersonIterator.getPersonIterator(PersonQuery.java:91)
	... 5 more
Caused by: java.net.SocketException: Socket closed
	at java.net.SocketInputStream.read(SocketInputStream.java:183)
	at java.net.SocketInputStream.read(SocketInputStream.java:121)
	at okio.Okio$2.read(Okio.java:138)
	at okio.AsyncTimeout$2.read(AsyncTimeout.java:238)
	... 34 more&lt;/PRE&gt;&lt;P&gt;the&amp;nbsp;listSitePeopleByRole mthod is the following.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT color="#339966"&gt;/* createQuery(siteId, role) return the query : PATH:"/sys:system/sys:authorities/cm:GROUP_site_&amp;lt;siteId&amp;gt;_&amp;lt;role&amp;gt;/*" AND TYPE:"cm:person"
*/&lt;/FONT&gt;
RequestQuery requestQuery = new RequestQuery().query(createQuery(siteId, role)).language(RequestQuery.LanguageEnum.AFTS);

RequestPagination requestPagination = new RequestPagination().skipCount(skipCount).maxItems(maxItems);
RequestSortDefinition requestSort = new RequestSortDefinition().field("id").ascending(true);

QueryBody queryBody = new QueryBody().query(requestQuery).paging(requestPagination).sort(Collections.singletonList(requestSort)).include(Arrays.asList("properties"));

return &lt;STRONG&gt;alfrescoClient.getSearchAPI().searchCall(queryBody).execute()&lt;/STRONG&gt;.body().getList().stream().map(nodeRep -&amp;gt; getPerson(role, nodeRep)).collect(Collectors.toList());&lt;/PRE&gt;</description>
    <pubDate>Mon, 27 Feb 2023 16:54:50 GMT</pubDate>
    <dc:creator>malekgn</dc:creator>
    <dc:date>2023-02-27T16:54:50Z</dc:date>
    <item>
      <title>java.net.SocketTimeoutException: timeout while calling a REST API</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/java-net-sockettimeoutexception-timeout-while-calling-a-rest-api/m-p/140236#M37490</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I created a batch to get information about sites, persons and documents.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The rest API called is :&amp;nbsp;&lt;A href="http://localhost:8080/alfresco/api/-default-/public/search/versions/1/search" target="_blank" rel="noopener nofollow noreferrer"&gt;/alfresco/api/-default-/public/search/versions/1/search&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;The user calling the webservice is &lt;STRONG&gt;admin&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;The query passed in the body is in &lt;STRONG&gt;afts&lt;/STRONG&gt; language.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I used the&amp;nbsp;&lt;A href="https://github.com/Alfresco/alfresco-client-sdk" target="_blank" rel="noopener nofollow noreferrer"&gt;alfresco-client-sdk&lt;/A&gt; project to call the webservices and search for information.&amp;nbsp;&lt;BR /&gt;The project is documented in &lt;A href="https://hub.alfresco.com/t5/alfresco-content-services-blog/alfresco-java-client-sdk-usage-part-9-queries-search/ba-p/292657" target="_blank" rel="noopener nofollow noreferrer"&gt;this blog&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Everything works well on my machine. But, when I deploy it on the PROD which a unix envirement (ubuntu), A&amp;nbsp;&lt;STRONG&gt;java.net.SocketTimeoutException&lt;/STRONG&gt; was thrown &lt;U&gt;after calling the webservice more than 20 times&lt;/U&gt; (but with different afts queries).&lt;BR /&gt;&lt;BR /&gt;The error message is the following.&lt;/P&gt;&lt;PRE&gt;Caused by: java.net.SocketTimeoutException: timeout
	at okio.Okio$3.newTimeoutException(Okio.java:210)
	at okio.AsyncTimeout.exit(AsyncTimeout.java:288)
	at okio.AsyncTimeout$2.read(AsyncTimeout.java:242)
	at okio.RealBufferedSource.indexOf(RealBufferedSource.java:325)
	at okio.RealBufferedSource.indexOf(RealBufferedSource.java:314)
	at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:210)
	at okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:186)
	at okhttp3.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127)
	at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:53)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:145)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at com.alfresco.client.AbstractClient$BasicAuthInterceptor.intercept(AbstractClient.java:254)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
	at okhttp3.RealCall.execute(RealCall.java:60)
	at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
	at com.custom.service.PeopleService.listSitePeopleByRole(PeopleService.java:84)
	at com.custom.batch.query.PersonQuery$PersonIterator.getPersonIterator(PersonQuery.java:91)
	... 5 more
Caused by: java.net.SocketException: Socket closed
	at java.net.SocketInputStream.read(SocketInputStream.java:183)
	at java.net.SocketInputStream.read(SocketInputStream.java:121)
	at okio.Okio$2.read(Okio.java:138)
	at okio.AsyncTimeout$2.read(AsyncTimeout.java:238)
	... 34 more&lt;/PRE&gt;&lt;P&gt;the&amp;nbsp;listSitePeopleByRole mthod is the following.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT color="#339966"&gt;/* createQuery(siteId, role) return the query : PATH:"/sys:system/sys:authorities/cm:GROUP_site_&amp;lt;siteId&amp;gt;_&amp;lt;role&amp;gt;/*" AND TYPE:"cm:person"
*/&lt;/FONT&gt;
RequestQuery requestQuery = new RequestQuery().query(createQuery(siteId, role)).language(RequestQuery.LanguageEnum.AFTS);

RequestPagination requestPagination = new RequestPagination().skipCount(skipCount).maxItems(maxItems);
RequestSortDefinition requestSort = new RequestSortDefinition().field("id").ascending(true);

QueryBody queryBody = new QueryBody().query(requestQuery).paging(requestPagination).sort(Collections.singletonList(requestSort)).include(Arrays.asList("properties"));

return &lt;STRONG&gt;alfrescoClient.getSearchAPI().searchCall(queryBody).execute()&lt;/STRONG&gt;.body().getList().stream().map(nodeRep -&amp;gt; getPerson(role, nodeRep)).collect(Collectors.toList());&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Feb 2023 16:54:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/java-net-sockettimeoutexception-timeout-while-calling-a-rest-api/m-p/140236#M37490</guid>
      <dc:creator>malekgn</dc:creator>
      <dc:date>2023-02-27T16:54:50Z</dc:date>
    </item>
  </channel>
</rss>

