mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 18:47:38 +01:00
Implement connection timeout (#4081)
This commit is contained in:
parent
526ed37a28
commit
55ecc1ae8f
1 changed files with 9 additions and 2 deletions
|
@ -10,6 +10,7 @@ import org.bitcoins.tor.{Socks5Connection, Socks5ProxyParams}
|
||||||
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
|
import scala.concurrent.duration.DurationInt
|
||||||
import scala.concurrent.{Future, Promise}
|
import scala.concurrent.{Future, Promise}
|
||||||
|
|
||||||
class DLCClient(
|
class DLCClient(
|
||||||
|
@ -36,7 +37,14 @@ class DLCClient(
|
||||||
remoteAddress
|
remoteAddress
|
||||||
}
|
}
|
||||||
context.become(connecting(peer))
|
context.become(connecting(peer))
|
||||||
IO(Tcp) ! Tcp.Connect(peerOrProxyAddress)
|
|
||||||
|
//currently our request timeout for requests sent to the backend is 60 seconds
|
||||||
|
//so we need the connection timeout to occur before the request times out
|
||||||
|
//when a user tries to submit an accept to the backend
|
||||||
|
//see: https://github.com/bitcoin-s/bitcoin-s/issues/4080
|
||||||
|
val connectionTimeout = 45.seconds
|
||||||
|
IO(Tcp) ! Tcp.Connect(peerOrProxyAddress,
|
||||||
|
timeout = Some(connectionTimeout))
|
||||||
}
|
}
|
||||||
|
|
||||||
def connecting(peer: Peer): Receive = LoggingReceive {
|
def connecting(peer: Peer): Receive = LoggingReceive {
|
||||||
|
@ -44,7 +52,6 @@ class DLCClient(
|
||||||
val ex = c.cause.getOrElse(new IOException("Unknown Error"))
|
val ex = c.cause.getOrElse(new IOException("Unknown Error"))
|
||||||
log.error(s"Cannot connect to ${cmd.remoteAddress} ", ex)
|
log.error(s"Cannot connect to ${cmd.remoteAddress} ", ex)
|
||||||
throw ex
|
throw ex
|
||||||
|
|
||||||
case Tcp.Connected(peerOrProxyAddress, _) =>
|
case Tcp.Connected(peerOrProxyAddress, _) =>
|
||||||
val connection = sender()
|
val connection = sender()
|
||||||
peer.socks5ProxyParams match {
|
peer.socks5ProxyParams match {
|
||||||
|
|
Loading…
Add table
Reference in a new issue