immutant 2016-12-15

@xandrews has joined the channel

Hi all, I'm seeing some peculiar Undertow errors, wonder if anyone has seen something similar?

2016-12-15 16:30:15,890 [XNIO-1 task-1] ERROR io.undertow.request: UT005071: Undertow request failed HttpServerExchange{ GET / request {X-Real-IP=[xxxx], Accept=[*/*], X-Amzn-Trace-Id=[Root=1-5852c517-5e570c000e2261a46ec0e6a9], Accept-Encoding=[gzip, deflate], User-Agent=[HTTPie/0.9.6], Connection=[upgrade], X-Forwarded-Proto=[http], X-Forwarded-Port=[80], X-Forwarded-For=[yyyy, zzzz], Host=[]} response {Server=[undertow]}}
java.lang.ClassCastException: null

I'm seeing this specifically when requesting an insecure page

@timgilbert: is there a stack trace at all?

Sadly, no

I have immutant behind an AWS application load balancer which is termintating SSL and then forwarding to immutant

When I request a secure page from the load balancer, everything is kosher. But when I request an insecure page, I get the above error in the logs

Wondering if it's related to the Connection=[upgrade] bit or something

@timgilbert are you saying there is no stack trace or you can't access the logs with the stack trace?

There is no stack trace, like each http request outputs literally just the block of logs above

All of this is working fine over http running on localhost, BTW, so it seems like possibly some stuff added from the load-balancer to the EC2 instance might be throwing a spanner into the works

what version of immutant are you using?

[org.immutant/web "2.1.5"]

k, thanks. trying something locally to see if I can reproduce

Cool, thanks. Let me know if there's info I can provide.

well, that didn't work

I thought maybe the presence of a Connection: upgrade without an Upgrade: header was triggering it, but no

Hmm, yeah

I do have some code that's specifically looking for http connections and redirecting them, maybe it's an obscure bug in there

is this an uberjar, or are you running WildFly?

Anyways, I'll keep hacking. Thanks for looking anyways

This is an uberjar, running under a AWS Java SE Elastic Beanstalk environment

I think there is a way to register an error handler - possibly the default one is what gives you the log message

looking for that now

Hmm, interesting

line 202 is where your handler gets (eventually) called. If you could wrap your top-level handler in a try/catch, that might tell you something

but there are probably other handlers in the chain that get called before your code, so the issue could be there as well

I think I may have found a bug in my code actually, where some ring middleware was returning this:

(fn [request]
  (moved-permanently secure-url))
...instead of just (moved-permanently secure-url)

Which maybe would explain the ClassCastException

Will mess with it and let you know

cool, I'm here to help if that doesn't fix it

Ok, yes, that was indeed the problem. Thanks for your help!

I obviously need to set up some better exception logging somewhere. I do see stack traces for most things, but this one just gave me the one line.