mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 10:46:42 +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.net.InetSocketAddress
|
||||
import scala.concurrent.duration.DurationInt
|
||||
import scala.concurrent.{Future, Promise}
|
||||
|
||||
class DLCClient(
|
||||
|
@ -36,7 +37,14 @@ class DLCClient(
|
|||
remoteAddress
|
||||
}
|
||||
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 {
|
||||
|
@ -44,7 +52,6 @@ class DLCClient(
|
|||
val ex = c.cause.getOrElse(new IOException("Unknown Error"))
|
||||
log.error(s"Cannot connect to ${cmd.remoteAddress} ", ex)
|
||||
throw ex
|
||||
|
||||
case Tcp.Connected(peerOrProxyAddress, _) =>
|
||||
val connection = sender()
|
||||
peer.socks5ProxyParams match {
|
||||
|
|
Loading…
Add table
Reference in a new issue