Fixed IPC connection issue
This commit is contained in:
parent
ac4afd3d50
commit
41ea4872be
|
@ -147,7 +147,7 @@ open class Client<CONNECTION : Connection>(
|
||||||
when {
|
when {
|
||||||
// this is default IPC settings
|
// this is default IPC settings
|
||||||
remoteAddress.isEmpty() && config.enableIpc -> {
|
remoteAddress.isEmpty() && config.enableIpc -> {
|
||||||
connectIpc(connectionTimeoutSec)
|
connectIpc(connectionTimeoutSec = connectionTimeoutSec)
|
||||||
}
|
}
|
||||||
|
|
||||||
IPv4.isPreferred -> {
|
IPv4.isPreferred -> {
|
||||||
|
@ -323,9 +323,14 @@ open class Client<CONNECTION : Connection>(
|
||||||
while (timoutInNanos == 0L || System.nanoTime() - startTime < timoutInNanos) {
|
while (timoutInNanos == 0L || System.nanoTime() - startTime < timoutInNanos) {
|
||||||
try {
|
try {
|
||||||
val handshakeConnection = if (autoChangeToIpc) {
|
val handshakeConnection = if (autoChangeToIpc) {
|
||||||
buildIpcHandshake(ipcSubscriptionId, ipcPublicationId, handshakeTimeout, reliable)
|
buildIpcHandshake(
|
||||||
|
ipcSubscriptionId = ipcSubscriptionId,
|
||||||
|
ipcPublicationId = ipcPublicationId,
|
||||||
|
connectionTimeoutSec = handshakeTimeout,
|
||||||
|
reliable = reliable
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
buildUdpHandshake(handshakeTimeout, reliable)
|
buildUdpHandshake(connectionTimeoutSec = handshakeTimeout, reliable = reliable)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(handshakeConnection.clientInfo())
|
logger.info(handshakeConnection.clientInfo())
|
||||||
|
@ -356,9 +361,15 @@ open class Client<CONNECTION : Connection>(
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun buildIpcHandshake(ipcSubscriptionId: Int, ipcPublicationId: Int, connectionTimeoutSec: Int, reliable: Boolean): MediaDriverConnection {
|
private suspend fun buildIpcHandshake(ipcSubscriptionId: Int, ipcPublicationId: Int, connectionTimeoutSec: Int, reliable: Boolean): MediaDriverConnection {
|
||||||
|
if (remoteAddress == null) {
|
||||||
|
logger.info {
|
||||||
|
"IPC enabled."
|
||||||
|
}
|
||||||
|
} else {
|
||||||
logger.info {
|
logger.info {
|
||||||
"IPC for loopback enabled and aeron is already running. Auto-changing network connection from ${IP.toString(remoteAddress!!)} -> IPC"
|
"IPC for loopback enabled and aeron is already running. Auto-changing network connection from ${IP.toString(remoteAddress!!)} -> IPC"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MAYBE the server doesn't have IPC enabled? If no, we need to connect via network instead
|
// MAYBE the server doesn't have IPC enabled? If no, we need to connect via network instead
|
||||||
val ipcConnection = IpcMediaDriverConnection(streamIdSubscription = ipcSubscriptionId,
|
val ipcConnection = IpcMediaDriverConnection(streamIdSubscription = ipcSubscriptionId,
|
||||||
|
@ -373,10 +384,19 @@ open class Client<CONNECTION : Connection>(
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
if (remoteAddress == null) {
|
if (remoteAddress == null) {
|
||||||
// if we specified that we MUST use IPC, then we have to throw the exception, because there is no IPC
|
// if we specified that we MUST use IPC, then we have to throw the exception, because there is no IPC
|
||||||
throw ClientException("Unable to connect via IPC to server. No address was specified", e)
|
val clientException = ClientException("Unable to connect via IPC to server. No address was specified", e)
|
||||||
|
ListenerManager.cleanStackTraceInternal(clientException)
|
||||||
|
throw clientException
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (remoteAddress == null) {
|
||||||
|
// if we specified that we MUST use IPC, then we have to throw the exception, because there is no IPC
|
||||||
|
val clientException = ClientException("Unable to connect via IPC to server. No address was specified")
|
||||||
|
ListenerManager.cleanStackTraceInternal(clientException)
|
||||||
|
throw clientException
|
||||||
|
}
|
||||||
|
|
||||||
logger.info { "IPC for loopback enabled, but unable to connect. Retrying with address ${IP.toString(remoteAddress!!)}" }
|
logger.info { "IPC for loopback enabled, but unable to connect. Retrying with address ${IP.toString(remoteAddress!!)}" }
|
||||||
|
|
||||||
// try a UDP connection instead
|
// try a UDP connection instead
|
||||||
|
@ -485,6 +505,7 @@ open class Client<CONNECTION : Connection>(
|
||||||
} else {
|
} else {
|
||||||
ClientRejectedException("Connection to ${IP.toString(remoteAddress!!)} has incorrect class registration details!!")
|
ClientRejectedException("Connection to ${IP.toString(remoteAddress!!)} has incorrect class registration details!!")
|
||||||
}
|
}
|
||||||
|
ListenerManager.cleanStackTraceInternal(exception)
|
||||||
throw exception
|
throw exception
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user