swift - Vapor error H13 on Heroku -


my program seems work fine on heroku, after reloading page 3-4 times, crashes, , error h13: connection closed without response. however, works fine , without error when run on computer.

here 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 more here"]  func buildname (from arraya: [string], , arrayb: [string], , 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>"  //create droplet object let drop = droplet()  // register routes , handlers drop.get { req in   return buildname(from: arraya, and: arrayb, and: arrayc) }  // start server drop.run() 

what doing wrong?

let a: int = int(random() % (arraya.count + 1))

this line generate number may equal arraya.count. so, may produce fatal error: index out of range.

so, think reason.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -