scala - How timeout works in Dispatch -


at api there is:

val http = http.configure(_     .setconnectiontimeoutinms(1)   ) 

what config? use with:

.setmaxrequestretry(0) 

i fought failed future after timeout. future create that:

val f = http(u ok as.string)   f.map {     notificationclientconnectionparams.parsefromstring   } 

but instead of failure success long after timeout. how should work?

my test looks this:

val starttime = java.time.localtime.now() val f = tcputil2.registerclientviadispatch(clientheaders("12345", "123456789")) f onsuccess {   case c =>     println(s"success: $c")     println(java.time.duration.between(starttime, java.time.localtime.now()).tomillis) } f onfailure {   case e =>     println(s"failure:${e.getmessage}") } thread.sleep(2000) 

response time in hundreds of milliseconds , got success. bug of dispatch?

an http roundtrip goes through several phases (overly simplified):

  1. establishing connection
  2. connection established
  3. sending request payload
  4. request payload sent
  5. waiting response payload
  6. receiving response payload
  7. response payload received

from understand measure time between states 1 , 7.

setconnectiontimeoutinms comes async-http-client used dispatch internally. here's excerpt its documentation:

set maximum time in millisecond asynchttpclient can wait when connecting remote host

thus, method sets maximum time client wait between states 1 , 2.

there's setrequesttimeoutinms:

set maximum time in millisecond asynchttpclient wait response

this method seems set time between states 5 , 6 (or 7, i'm not sure one).


so here's what's happening in case. connect remote host, server accepts connection (the time between 1 , 2 small), future doesn't failed. there several options: either server takes lot of time prepare response before starts sending (the time between 5 , 6), or response big takes lot of time deliver (the time between 6 , 7), or both. since don't set request timeout, future not getting failed because of this.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -