Classified Classified - 1 year ago 153
HTTP Question

Taking a while for website to return 500 Internal server error

This is a followup question to my other question here on stack.

Not sure if this is a problem with play or this is normal results for a webserver. I am using play 2.1.2

I have a website that immediately returns http code 200 if things are working fine.
If the site has problems, for some reason, it doesn't immediately return a 500 Internal Server Error. It seems like it will take 5 min for it to finally return a 500 error.

Is this a problem with using the play framework to run our site or is there something else I should check as to why this is happening? I'm also using httplib from python to check the website.

I don't know what other details to add to help debug but hopefully the simple answer is the play framework is doing something to the site and doesn't reply with a 500 code until the time out (5 min) has passed.

UPDATE: Attached is the message from the server when I hit it with my script. This is on a test server so I'm expecting it to fail. I executed

ulimit -n 275
to cause an out of files error on the server.

This is the error I get from my script if I run it within 5 min of causing a problem:

got some exception
Traceback (most recent call last):
File "", line 27, in <module>
File "", line 24, in main
File "", line 16, in get_status_code
if resp == 200:
UnboundLocalError: local variable 'resp' referenced before assignment

However, if I wait 5+ min and then I run my script to check on the site, this is what I get:

didn't get a 200 http response. something wrong
this is the code we got: 500

These are the log msgs at the time I caused the out of file error. My script doesn't cause the webserver to record any additional messages but I run my script after I purposely cause the site/server to have problems so these msgs are from me causing an out of files error.

! @70jo4chan - Internal server error, for (GET) [/] ->

play.api.PlayException: Not initialized[?]
at play.core.ReloadableApplication.<init>(ApplicationProvider.scala:92) ~[play_2.10.jar:2.1.2]
at play.core.server.NettyServer$$anonfun$mainDev$1.apply(NettyServer.scala:273) ~[play_2.10.jar:2.1.2]
at play.core.server.NettyServer$$anonfun$mainDev$1.apply(NettyServer.scala:272) ~[play_2.10.jar:2.1.2]
at play.utils.Threads$.withContextClassLoader(Threads.scala:18) ~[play_2.10.jar:2.1.2]
at play.core.server.NettyServer$.mainDev(NettyServer.scala:271) ~[play_2.10.jar:2.1.2]
at play.core.server.NettyServer.mainDev(NettyServer.scala) ~[play_2.10.jar:2.1.2]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_71]
at sun.reflect.NativeMethodAccessorImpl.invoke( ~[na:1.7.0_71]
at sun.reflect.DelegatingMethodAccessorImpl.invoke( ~[na:1.7.0_71]
at java.lang.reflect.Method.invoke( ~[na:1.7.0_71]
at sbt.PlayCommands$$anonfun$53$$anonfun$55.apply(PlayCommands.scala:575) ~[na:na]
at sbt.PlayCommands$$anonfun$53$$anonfun$55.apply(PlayCommands.scala:507) ~[na:na]
at scala.Either$ ~[na:na]
at sbt.PlayCommands$$anonfun$53.apply(PlayCommands.scala:507) ~[na:na]
at sbt.PlayCommands$$anonfun$53.apply(PlayCommands.scala:487) ~[na:na]
at sbt.Command$$anonfun$sbt$Command$$apply1$1$$anonfun$apply$6.apply(Command.scala:72) ~[na:na]
at sbt.Command$.process(Command.scala:90) ~[na:na]
at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(MainLoop.scala:71) ~[na:na]
at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(MainLoop.scala:71) ~[na:na]
at sbt.State$$anon$2.process(State.scala:170) ~[na:na]
at sbt.MainLoop$$anonfun$next$1.apply(MainLoop.scala:71) ~[na:na]
at sbt.MainLoop$$anonfun$next$1.apply(MainLoop.scala:71) ~[na:na]
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18) ~[na:na]
at sbt.MainLoop$.next(MainLoop.scala:71) ~[na:na]
at sbt.MainLoop$.run(MainLoop.scala:64) ~[na:na]
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:53) ~[na:na]
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:50) ~[na:na]
at sbt.Using.apply(Using.scala:25) ~[na:na]
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:50) ~[na:na]
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:33) ~[na:na]
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:17) ~[na:na]
at sbt.MainLoop$.runLogged(MainLoop.scala:13) ~[na:na]
at ~[na:na]
at xsbt.boot.Launch$.run(Launch.scala:55) ~[na:na]
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45) ~[na:na]
at xsbt.boot.Launch$.launch(Launch.scala:69) ~[na:na]
at xsbt.boot.Launch$.apply(Launch.scala:16) ~[na:na]
at xsbt.boot.Boot$.runImpl(Boot.scala:31) ~[na:na]
at xsbt.boot.Boot$.main(Boot.scala:20) ~[na:na]
at xsbt.boot.Boot.main(Boot.scala) ~[na:na]

UPDATE #2: Forgot to mention I'm using play 2.1.2

Answer Source

When you use play run, your app will be started in dev mode. In this mode , the app itself will only really start when it gets the first request. Sometimes it happens that, even after the server is started and should be ready to accept requests, Play detects that something has changed and recompiles some things, leaving the browser "waiting" (I have noticed this behaviour in every Play 2.x version, but I'm not sure if it is something related to my setup or a bug). This can be the reason of those delays you are getting.

The best way to avoid this is to make sure everything is ready, using play copile and play start, or using play dist, which will provide you a file with your application ready to be used in production. See here for more information.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download