mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Set socket timeout to 5s (#3929)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com> Co-authored-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
03232047fd
commit
2ad703c5f8
1 changed files with 4 additions and 2 deletions
|
|
@ -41,6 +41,8 @@ class TCPInterface @AssistedInject constructor(service: RadioInterfaceService, @
|
|||
const val MAX_RETRIES_ALLOWED = Int.MAX_VALUE
|
||||
const val MIN_BACKOFF_MILLIS = 1 * 1000L // 1 second
|
||||
const val MAX_BACKOFF_MILLIS = 5 * 60 * 1000L // 5 minutes
|
||||
const val SOCKET_TIMEOUT = 5000
|
||||
const val SOCKET_RETRIES = 18
|
||||
const val SERVICE_PORT = NetworkRepository.SERVICE_PORT
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +108,7 @@ class TCPInterface @AssistedInject constructor(service: RadioInterfaceService, @
|
|||
|
||||
Socket(InetAddress.getByName(host), port).use { socket ->
|
||||
socket.tcpNoDelay = true
|
||||
socket.soTimeout = 500
|
||||
socket.soTimeout = SOCKET_TIMEOUT
|
||||
this@TCPInterface.socket = socket
|
||||
|
||||
BufferedOutputStream(socket.getOutputStream()).use { outputStream ->
|
||||
|
|
@ -119,7 +121,7 @@ class TCPInterface @AssistedInject constructor(service: RadioInterfaceService, @
|
|||
backoffDelay = MIN_BACKOFF_MILLIS
|
||||
|
||||
var timeoutCount = 0
|
||||
while (timeoutCount < 180) {
|
||||
while (timeoutCount < SOCKET_RETRIES) {
|
||||
try { // close after 90s of inactivity
|
||||
val c = inputStream.read()
|
||||
if (c == -1) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue