My program seems to work fine on Heroku, but after reloading the page 3-4 times, it crashes and I get an error message H13: Connection closed without response. However, it works fine and error-free when I run it on my computer.
Here is my code:
#if os(Linux)
import Glibc
#else
import Darwin
#endif
import Vapor
let arrayA: [String] = ["some strings here"]
let arrayB: [String] = ["more strings there"]
let arrayC: [String] = ["and some more here"]
func buildName (from arrayA: [String], and arrayB: [String], and arrayC: [String]) -> String {
#if os(Linux)
let a: Int = Int(random() % (arrayA.count + 1))
let b: Int = Int(random() % (arrayB.count + 1))
let c: Int = Int(random() % (arrayC.count + 1))
#else
let a: Int = Int(arc4random_uniform(UInt32(arrayA.count)))
let b: Int = Int(arc4random_uniform(UInt32(arrayB.count)))
let c: Int = Int(arc4random_uniform(UInt32(arrayC.count)))
#endif
return (arrayA[a] + " " + arrayB[b] + " " + arrayC[c])
}
let defaultHead: String = "<head><meta charset='utf-8'></head>"
let drop = Droplet()
drop.get { req in
return buildName(from: arrayA, and: arrayB, and: arrayC)
}
drop.run()
What am I doing wrong?
source
share