https://kotlinlang.org logo
#http4k
Title
# http4k
p

pabl0rg

09/21/2020, 9:43 PM
Hi @dave after upgrading from http4k 3.251 to 3.252 (or beyond) i get 403 errors when my app receives the callback from an oauth provider. This happens using the Apache server. If I switch to Jetty or Netty, the 403 problem goes away. Is there something special I should configure when using the Apache server?
d

dave

09/21/2020, 10:42 PM
Hmm. That's release was when we switched to the new version (5) of Apache server, so it looks like there might tweaking to be done to the server implementation using the A5 APIs.. For the moment you can just use http4k-server-apache4 which should solve your problem. Can you raise an issue with it - we might need a contract of some type adding to make sure it works across the board.
p

pabl0rg

09/21/2020, 11:55 PM
Thanks!
I also hit some weird issues with the apache 5 client, so i'll switch to apache 4. Here's a stack trace where i get an error.
Copy code
java.net.SocketException · Socket is closed
Socket.java:1155java.net.Socket.setSoTimeout	
BaseSSLSocketImpl.java:633sun.security.ssl.BaseSSLSocketImpl.setSoTimeout	
SSLSocketImpl.java:2577sun.security.ssl.SSLSocketImpl.setSoTimeout	
BHttpConnectionBase.java:269org.apache.hc.core5.http.impl.io.BHttpConnectionBase.fillInputBuffer	
BHttpConnectionBase.java:277org.apache.hc.core5.http.impl.io.BHttpConnectionBase.awaitInput	
BHttpConnectionBase.java:285org.apache.hc.core5.http.impl.io.BHttpConnectionBase.isDataAvailable	
DefaultBHttpClientConnection.java:65org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection.isDataAvailable	
DefaultBHttpClientConnection.java:171org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection$1.checkForEarlyResponse	
DefaultBHttpClientConnection.java:187org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection$1.write	
SessionOutputBufferImpl.java:117org.apache.hc.core5.http.impl.io.SessionOutputBufferImpl.flushBuffer	
SessionOutputBufferImpl.java:126org.apache.hc.core5.http.impl.io.SessionOutputBufferImpl.flush	
ContentLengthOutputStream.java:99org.apache.hc.core5.http.impl.io.ContentLengthOutputStream.flush	
ByteArrayEntity.java:131org.apache.hc.core5.http.io.entity.ByteArrayEntity.writeTo	
DefaultBHttpClientConnection.java:209org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection.sendRequestEntity	
HttpRequestExecutor.java:148org.apache.hc.core5.http.impl.io.HttpRequestExecutor.execute	
HttpRequestExecutor.java:225org.apache.hc.core5.http.impl.io.HttpRequestExecutor.execute	
PoolingHttpClientConnectionManager.java:600org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager$InternalConnectionEndpoint.execute	
InternalExecRuntime.java:220org.apache.hc.client5.http.impl.classic.InternalExecRuntime.execute	
MainClientExec.java:107org.apache.hc.client5.http.impl.classic.MainClientExec.execute	
ExecChainElement.java:51org.apache.hc.client5.http.impl.classic.ExecChainElement.execute	
ExecChainElement.java:57org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed	
ConnectExec.java:181org.apache.hc.client5.http.impl.classic.ConnectExec.execute	
ExecChainElement.java:51org.apache.hc.client5.http.impl.classic.ExecChainElement.execute	
ExecChainElement.java:57org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed	
ProtocolExec.java:169org.apache.hc.client5.http.impl.classic.ProtocolExec.execute	
ExecChainElement.java:51org.apache.hc.client5.http.impl.classic.ExecChainElement.execute	
ExecChainElement.java:57org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed	
HttpRequestRetryExec.java:93org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute	
ExecChainElement.java:51org.apache.hc.client5.http.impl.classic.ExecChainElement.execute	
ExecChainElement.java:57org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed	
ContentCompressionExec.java:128org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute	
ExecChainElement.java:51org.apache.hc.client5.http.impl.classic.ExecChainElement.execute	
ExecChainElement.java:57org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed	
RedirectExec.java:116org.apache.hc.client5.http.impl.classic.RedirectExec.execute	
ExecChainElement.java:51org.apache.hc.client5.http.impl.classic.ExecChainElement.execute	
InternalHttpClient.java:178org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute	
CloseableHttpClient.java:75org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute	
CloseableHttpClient.java:89org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute	
ApacheClient.kt:57org.http4k.client.ApacheClient$invoke$1.invoke	
ApacheClient.kt:47org.http4k.client.ApacheClient$invoke$1.invoke	
ClientFilters.kt:56org.http4k.filter.ClientFilters$SetHostFrom$invoke$1$1.invoke	
ClientFilters.kt:52org.http4k.filter.ClientFilters$SetHostFrom$invoke$1$1.invoke	
Http4k.kt:21org.http4k.core.Http4kKt$then$2.invoke	
Http4k.kt:-1org.http4k.core.Http4kKt$then$2.invoke	
AccessTokenFetcher.kt:46org.http4k.security.AccessTokenFetcher.fetch	
OAuthCallback.kt:27org.http4k.security.OAuthCallback.invoke	
OAuthCallback.kt:11org.http4k.security.OAuthCallback.invoke	
internal.kt:107org.http4k.routing.TemplateRoutingHttpHandler$match$1.invoke	
internal.kt:97org.http4k.routing.TemplateRoutingHttpHandler$match$1.invoke	
routing.kt:29org.http4k.routing.RouterMatch$MatchingHandler.invoke	
internal.kt:77org.http4k.routing.AggregateRoutingHttpHandler.invoke	
internal.kt:69org.http4k.routing.AggregateRoutingHttpHandler.invoke	
ServerFilters.kt:233org.http4k.filter.ServerFilters$CatchLensFailure$2$1.invoke	
ServerFilters.kt:43org.http4k.filter.ServerFilters$CatchLensFailure$2$1.invoke	
ResponseFilters.kt:24org.http4k.filter.ResponseFilters$Tap$invoke$1$1.invoke	
ResponseFilters.kt:21org.http4k.filter.ResponseFilters$Tap$invoke$1$1.invoke	
RequestFilters.kt:23org.http4k.filter.RequestFilters$Tap$invoke$1$1.invoke	
RequestFilters.kt:19org.http4k.filter.RequestFilters$Tap$invoke$1$1.invoke	
Log500.kt:13gt.kemik.http.Log500$invoke$1.invoke	
Log500.kt:10gt.kemik.http.Log500$invoke$1.invoke	
Http4k.kt:21org.http4k.core.Http4kKt$then$2.invoke	
Http4k.kt:-1org.http4k.core.Http4kKt$then$2.invoke	
ServerFilters.kt:252org.http4k.filter.ServerFilters$CatchAll$invoke$1$1.invoke	
ServerFilters.kt:248org.http4k.filter.ServerFilters$CatchAll$invoke$1$1.invoke	
Http4k.kt:21org.http4k.core.Http4kKt$then$2.invoke	
Http4k.kt:-1org.http4k.core.Http4kKt$then$2.invoke	
Apache4Server.kt:36org.http4k.server.Http4kApache4RequestHandler.handle	
HttpService.java:437org.apache.http.protocol.HttpService.doService	
HttpService.java:342org.apache.http.protocol.HttpService.handleRequest	
Worker.java:66org.apache.http.impl.bootstrap.Worker.run	
ThreadPoolExecutor.java:1149java.util.concurrent.ThreadPoolExecutor.runWorker	
ThreadPoolExecutor.java:624java.util.concurrent.ThreadPoolExecutor$Worker.run	
Thread.java:748java.lang.Thread.run
<del>This is how i configured the Apache 5 client:</del> Nevermind. I noticed just now that the client used for OAuth was not configured (just the default)
d

dave

09/22/2020, 3:27 PM
Can you stick a debugging filter in the stack and post what causes the 403?
We can obvs look at it later, just curious.
If you've got time and the inclination, you could check out the http4k-by-example repo and switch to Apache 5 server, then try running RunnableEenvironment to see if it's something related to your specific env
🆗 1