akka http - Outgoing connection stream closed -
i have actor behaviour:
def receive: receive = { case info(message) => val res = send("info:" + message) installackhook(res) case warning(message) => val res = send("warning:" + message) installackhook(res) case error(message) => val res = send("error:" + message) installackhook(res) } private def installackhook[t](fut: future[t]): unit = { val answerto = sender() fut.oncomplete { case success(_) => answerto ! "ok" case failure(ex) => answerto ! ex } } private def send(message: string): future[httpresponse] = { import context.system val payload: payload = payload(text = message, username = slackconfig.username, icon_url = slackconfig.iconurl, icon_emoji = slackconfig.iconemoji, channel = slackconfig.channel) .validate http().singlerequest(requestbuilding.post(slackconfig.hookaddress, payload)) }
and test
val actorref = system.actorof(slackhookactor.props(slackendpointconfig(webhookurl,iconemoji = some(":ghost:")))) actorref ! error("some error message") actorref ! warning("some warning message") actorref ! info("some info message") receiven(3)
and in afterall()
method shutdown on actor system using testkit
.
it works, request makes server, there errors akka streams part:
[error] [06/26/2015 11:34:55.118] [slackhooktestingsystem-akka.actor.default-dispatcher-10] [actorsystem(slackhooktestingsystem)] outgoing request stream error (akka.stream.abruptterminationexception) [error] [06/26/2015 11:34:55.120] [slackhooktestingsystem-akka.actor.default-dispatcher-13] [actorsystem(slackhooktestingsystem)] outgoing request stream error (akka.stream.abruptterminationexception) [error] [06/26/2015 11:34:55.121] [slackhooktestingsystem-akka.actor.default-dispatcher-8] [actorsystem(slackhooktestingsystem)] outgoing request stream error (akka.stream.abruptterminationexception)
seems since have future completed outgoing connection should closed, bug or missing sth?
you need shut down http connection pools, like
http().shutdownallconnectionpools().oncomplete{ _ => system.shutdown() }
maybe akka http testkit provides helpers
Comments
Post a Comment