phax/peppol-commons

Caching on SMPClientReadOnly getServiceGroup

Closed this issue · 2 comments

Hello @phax,

I have a question about caching in the peppol-smp-client SMPClientReadOnly. I noticed that when I do a getServiceGroup lookup before registration (returning 404) that after registration I still get the 404 during lookup after saving the ServiceGroup for about 15 minutes even if the ServiceGroup is able to be found by other applications (for example the helger participant information tool).
If we do a lookup with the helger participant information tool before registration it looks like the same caching is happening here.

However I am not able to find any caching being done in the smp-client (only caching I could find was InetAddressCachePolicy and we use default 30s).

Does the SML itself do any caching on our requests meaning there is no solution for this issue or am I missing some caching implementation?

Kind regards and thanks in advance!

Some informational stacktraces:

Cached lookup

java.net.UnknownHostException: B-03a...64.iso6523-actorid-upis.acc.edelivery.tech.ec.europa.eu
	at java.base/java.net.InetAddress$CachedLookup.get(InetAddress.java:988)
	at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1818)
	at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1688)
	at org.apache.hc.client5.http.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:43)
	at org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:143)
	at org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:447)
	at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:162)
	at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:172)
	at org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:142)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:192)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:96)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:152)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:115)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:170)
	at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:245)
	at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:188)
	at com.helger.httpclient.HttpClientManager.execute(HttpClientManager.java:137)
	at com.helger.smpclient.httpclient.AbstractGenericSMPClient.executeRequest(AbstractGenericSMPClient.java:363)
	at com.helger.smpclient.httpclient.AbstractGenericSMPClient.executeGenericRequest(AbstractGenericSMPClient.java:401)
	at com.helger.smpclient.peppol.SMPClientReadOnly.getCompleteServiceGroup(SMPClientReadOnly.java:275)
	at com.helger.smpclient.peppol.SMPClientReadOnly.getCompleteServiceGroup(SMPClientReadOnly.java:307)
	at com.helger.smpclient.peppol.SMPClientReadOnly.getCompleteServiceGroupOrNull(SMPClientReadOnly.java:340)

No Caching

java.net.UnknownHostException: B-03a...64.iso6523-actorid-upis.acc.edelivery.tech.ec.europa.eu nodename nor servname provided, or not known
	at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
	at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:52)
	at java.base/java.net.InetAddress$PlatformResolver.lookupByName(InetAddress.java:1211)
	at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1828)
	at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:1139)
	at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1818)
	at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1688)
	at org.apache.hc.client5.http.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:43)
	at org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:143)
	at org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:447)
	at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:162)
	at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:172)
	at org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:142)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:192)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:96)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:152)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:115)
	at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
	at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:170)
	at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:245)
	at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:188)
	at com.helger.httpclient.HttpClientManager.execute(HttpClientManager.java:137)
	at com.helger.smpclient.httpclient.AbstractGenericSMPClient.executeRequest(AbstractGenericSMPClient.java:363)
	at com.helger.smpclient.httpclient.AbstractGenericSMPClient.executeGenericRequest(AbstractGenericSMPClient.java:401)
	at com.helger.smpclient.peppol.SMPClientReadOnly.getCompleteServiceGroup(SMPClientReadOnly.java:275)
	at com.helger.smpclient.peppol.SMPClientReadOnly.getCompleteServiceGroup(SMPClientReadOnly.java:307)
	at com.helger.smpclient.peppol.SMPClientReadOnly.getCompleteServiceGroupOrNull(SMPClientReadOnly.java:340)
phax commented

Hi @Jef-VDD,
this is the DNS Client caching that happens "everywhere" implicitly. There is caching inside the Java Runtime, there is multiple caching on OS level (depending on the OS the application is running on) and there is caching on the DNS Server your application is using.
I think the maximum TTL is one hour, so it takes no longer then 1h until the cache is refreshed.

hth

Thanks for the quick response! I'm happy to have the confirmation that there is no caching by the peppol-smp-client. I'll have to further at what level we are doing our DNS caching.