diff --git a/docs/configuration.md b/docs/configuration.md index 9a3e056f..cfbad8b4 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -84,6 +84,14 @@ MaxTopicTitleLength - The maximum length that a topic can be. Please note that t MaxUsernameLength - The maximum length that a user's name can be. Please note that this measures the number of bytes and may differ from language to language with it being equal to a letter in English and being two bytes in others. +ReadTimeout - The number of seconds that we are allowed to take to fully read a request. Defaults to 5. + +WriteTimeout - The number of seconds that a route is allowed to run for before the request is automatically terminated. Defaults to 10. + +IdleTimeout - The number of seconds that a Keep-Alive connection will be kept open before being closed. You might to tweak this, if you use Cloudflare or similar. Defaults to 120. + +Related: https://support.cloudflare.com/hc/en-us/articles/212794707-General-Best-Practices-for-Load-Balancing-at-your-origin-with-Cloudflare + # Database @@ -117,6 +125,6 @@ DebugMode - Outputs a basic level of information about what Gosora is doing to h SuperDebug - Outputs a detailed level of information about what Gosora is doing to help ease debugging. Warning: This may cause severe slowdowns in Gosora. -TemplateDebug - Output a detailed level of information about what Gosora is doing during the template transpilation step. Warning: Huge amounts of information will be dumped into the logs. +TemplateDebug - Output a detailed level of information about what Gosora is doing during the template transpilation step. Warning: Large amounts of information will be dumped into the logs. NoFsnotify - Whether you want to disable the file watcher which automatically reloads assets whenever they change. \ No newline at end of file diff --git a/main.go b/main.go index f98cbb19..e9047aad 100644 --- a/main.go +++ b/main.go @@ -473,14 +473,20 @@ func startServer() { rtime := common.Config.ReadTimeout if rtime == 0 { rtime = 5 + } else if rtime == -1 { + rtime = 0 } wtime := common.Config.WriteTimeout if wtime == 0 { wtime = 10 + } else if wtime == -1 { + wtime = 0 } itime := common.Config.IdleTimeout if itime == 0 { itime = 120 + } else if itime == -1 { + itime = 0 } return &http.Server{ Addr: addr, diff --git a/public/global.js b/public/global.js index a653afd3..c3f54a22 100644 --- a/public/global.js +++ b/public/global.js @@ -8,7 +8,7 @@ var conn = false; var selectedTopics = []; var attachItemCallback = function(){} var baseTitle = document.title; -var wsBackoff = false; +var wsBackoff = 0; // Topic move var forumToMoveTo = 0; @@ -214,8 +214,11 @@ function runWebSockets() { conn = false; console.log("The WebSockets connection was closed"); let backoff = 1000; - if(wsBackoff) backoff = 8000; - wsBackoff = true; + if(wsBackoff < 0) wsBackoff = 0; + else if(wsBackoff > 12) backoff = 13000; + else if(wsBackoff > 5) backoff = 7000; + wsBackoff++; + setTimeout(() => { var alertMenuList = document.getElementsByClassName("menu_alerts"); for(var i = 0; i < alertMenuList.length; i++) { @@ -223,6 +226,11 @@ function runWebSockets() { } runWebSockets(); }, 60 * backoff); + + if(wsBackoff > 0) { + if(wsBackoff <= 5) setTimeout(() => wsBackoff--, 60 * 4000); + else if(wsBackoff <= 12) setTimeout(() => wsBackoff--, 60 * 20000); + } } conn.onmessage = (event) => {