1

I am referring to the set up custom error responses for Google Appengine as described in the documentation for Configuring with app.yaml particulary on the following code:

error_handlers  
- error_code: default  
  file: default_error.html   

- error_code: over_quota   
  file: over_quota.html  

Currently I am running an application by putting the code in separate modules where python run as a default module configured in app.yaml. Other module's runtime are in php and java which are run simultaneously thru dispatch.yaml as shown below:

application: app-id
dispatch:
# Send favicon to default module - python
- url: "*/favicon.ico"
  module: default

# Send script to java module
- url: "*/scripts/*"
  module: javamodule

# Send others to php module
- url: "*/*"
  module: phpmodule

Everything seems to work as expected but I need to know what I have been missing here since I have put the above error_handlers in the app.yaml but fail to show either default_error.html on page not found (error code: 404) nor over_quota.html on over quota (error code:503).

I have put them also in other modules with also no response. I have also make sure that the path to the error response file does not overlap with static file handler paths and that the both html file are less than 10 kilobytes.

Harshal Patil
  • 6,284
  • 8
  • 37
  • 55
Chetabahana
  • 7,806
  • 2
  • 50
  • 70
  • 404 is not one of the supported error. For that you can use a simple handler to generate the custom error page. For 503, do you see the corresponding entry in your log? – Mars Oct 30 '14 at 22:20
  • I remember that there was a message log saying problem due to over service limit. I have been trying to search in my log but don't know how to find it. – Chetabahana Nov 06 '14 at 12:22
  • Here is the log when overquota (Error code 503): 11:39:06.899 503 970 B 17ms / 208.122.6.102 - - [18/Nov/2014:20:39:06 -0800] "GET / HTTP/1.1" 503 970 - "FreeWebMonitoring SiteChecker/0.2 (+http://www.freewebmonitoring.com/bot.html)" "tophyips.info" ms=17 cpu_ms=0 cpm_usd=0.000108 app_engine_release=1.9.16 – Chetabahana Nov 19 '14 at 04:48

1 Answers1

0

Accidentally I find a way to solve this problem of error routing on my application in Google AppEngine.

By a requirement I made and deploy my module with a new name as well as rearrange and update the module name and document flow on disptach.yaml so it come to like this:

dispatch:
# Send styles to python module (default module)
- url: "*/styles/*"
  module: default

# Send script to java module
- url: "*/scripts/*"
  module: javamodule

# Send images to go module
- url: "*/images/*"
  module: gomodule

# Send others to php module
- url: "*/*"
  module: newphpmodule

I came to a conclusion what was happen after change my module name that bring the error routing working where the application is now showing the over_quota.html on over quota (error code 503).

For errorcode 404 I agree with the comment from Mars above that I shall use a simple handler to generate the custom error page.

It has also make sure that the path to the error response file does not overlap with static file handler paths in module yaml file. So if your error page is html then every handler that point to the error page has to be uncommented like below:

#- url: /(.*\.(htm|html))$
#  mime_type: text/html
#  static_files: \1
#  upload: (.*\.(htm|html))$

Moreover if we have settled to make the over_quota.html is enable to be displayed in case over quota is happen, is it a convenient way to let the user or visitor know when the site will back online.

I have set my application billing to daily type so it will reset back to zero on midnight time as well as my daily quota. I got a code to count the time from user local time every where in the world to this particularly server midnight time using javascript (no need jquery) as bellow:

<span id="timer"></span>
<script>
var t=document.getElementById("timer"), wd=window||document, d=new Date(), md=new Date(); 
var tzone=md.getTimezoneOffset()/60; //get visitor timezone, (server timezone is -7,0)
md.setHours(24-(tzone-7)); md.setMinutes(0); md.setSeconds(0); md.setMilliseconds(0);
var dif=((md.getTime()-d.getTime())/1000);
var timer=setInterval(counter, 1000);
function counter(){
    dif=dif-1; var h=Math.floor(dif/3600%24), m=Math.floor((dif%3600)/60), s=Math.floor(dif%60);
    if(h>10){clearInterval(timer); t.innerHTML="0:00:00"; wd.location.reload(true);}
    else{t.innerHTML=h+":"+(m<10?'0'+m:m)+":"+(s<10?'0'+s:s);}
}
</script>

See it on action here

Chetabahana
  • 7,806
  • 2
  • 50
  • 70