Skip to content

Commit 61755d6

Browse files
fix: Attempt correction of grpc trying to use unix sockets instead of tcp
1 parent 07f1a85 commit 61755d6

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object Versions {
1414
const val EXPOSED = "0.61.0"
1515
const val FLYWAYDB = "11.11.2"
1616
const val GOOGLE_TRUTH = "1.4.4"
17-
const val GRPC = "1.75.0"
17+
const val GRPC = "1.74.0"
1818
const val GRPC_KOTLIN = "1.4.3"
1919
const val HIKARICP = "7.0.2"
2020
const val I2P_CRYPTO = "0.3.0"
@@ -36,7 +36,7 @@ object Versions {
3636
const val MAVEN_PUBLISH = "0.34.0"
3737
const val MOCKK = "1.14.5"
3838
const val POSTGRESQL = "42.7.7"
39-
const val PROTOBUF = "4.32.0"
39+
const val PROTOBUF = "4.31.1"
4040
const val PROTOBUF_PLUGIN = "0.9.5"
4141
const val QR_CODE_KOTLIN = "4.5.0"
4242
const val QUARTZ = "2.5.0"

newm-server/src/main/kotlin/io/newm/server/features/cardano/CardanoKoinModule.kt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.newm.server.features.cardano
22

3+
import io.github.oshai.kotlinlogging.KotlinLogging
34
import io.grpc.ManagedChannelBuilder
45
import io.grpc.Metadata
56
import io.grpc.stub.MetadataUtils
@@ -11,9 +12,11 @@ import io.newm.server.ktx.getSecureConfigString
1112
import io.newm.shared.ktx.getConfigBoolean
1213
import io.newm.shared.ktx.getConfigInt
1314
import io.newm.shared.ktx.getConfigString
15+
import java.util.concurrent.TimeUnit
1416
import kotlinx.coroutines.runBlocking
1517
import org.koin.dsl.module
16-
import java.util.concurrent.TimeUnit
18+
19+
private val log by lazy { KotlinLogging.logger {} }
1720

1821
val cardanoKoinModule =
1922
module {
@@ -33,19 +36,31 @@ val cardanoKoinModule =
3336
val port = environment.getConfigInt("newmChain.port")
3437
val jwt = runBlocking { environment.getSecureConfigString("newmChain.jwt") }
3538
val secure = environment.getConfigBoolean("newmChain.secure")
39+
40+
log.info { "Configuring gRPC channel for NewmChain:" }
41+
log.info { " Host: $host" }
42+
log.info { " Port: $port" }
43+
log.info { " Secure: $secure" }
44+
log.info { " Keep-alive time: 30 seconds" }
45+
log.info { " Keep-alive timeout: 20 seconds" }
46+
log.info { " Keep-alive without calls: true" }
47+
log.info { " Transport: ${if (secure) "TLS" else "Plaintext"}" }
48+
3649
val channel =
3750
ManagedChannelBuilder
38-
.forTarget("dns:///$host:$port")
51+
.forAddress(host, port)
52+
.keepAliveTime(30L, TimeUnit.SECONDS)
53+
.keepAliveTimeout(20L, TimeUnit.SECONDS)
54+
.keepAliveWithoutCalls(true)
3955
.apply {
40-
keepAliveTime(30L, TimeUnit.SECONDS)
41-
keepAliveTimeout(20L, TimeUnit.SECONDS)
42-
keepAliveWithoutCalls(true)
4356
if (secure) {
4457
useTransportSecurity()
4558
} else {
4659
usePlaintext()
4760
}
4861
}.build()
62+
63+
log.info { "gRPC channel created successfully for $host:$port" }
4964
NewmChainCoroutineStub(channel)
5065
.withInterceptors(
5166
MetadataUtils.newAttachHeadersInterceptor(

newm-server/src/test/kotlin/io/newm/server/grpc/GrpcTests.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import io.newm.chain.grpc.walletRequest
3131
import io.newm.chain.util.Constants
3232
import io.newm.server.features.cardano.repo.CardanoRepository.Companion.CHARLI3_NEWM_USD_NAME_PREPROD
3333
import io.newm.server.features.cardano.repo.CardanoRepository.Companion.CHARLI3_NEWM_USD_POLICY_PREPROD
34+
import java.util.concurrent.TimeUnit
3435
import kotlinx.coroutines.flow.take
3536
import kotlinx.coroutines.runBlocking
3637
import org.junit.jupiter.api.Disabled
@@ -77,6 +78,32 @@ class GrpcTests {
7778
)
7879
}
7980

81+
@Test
82+
@Disabled
83+
fun `test transport for ManagedChannelBuilder`() {
84+
// Test DNS resolution with secure transport and TCP-only configuration
85+
val secureChannel = ManagedChannelBuilder
86+
.forAddress("newm-chain.cardanostakehouse.com", 3737)
87+
.keepAliveTime(30L, TimeUnit.SECONDS)
88+
.keepAliveTimeout(20L, TimeUnit.SECONDS)
89+
.keepAliveWithoutCalls(true)
90+
.useTransportSecurity()
91+
.build()
92+
93+
assertThat(secureChannel).isNotNull()
94+
assertThat(secureChannel.isShutdown).isFalse()
95+
96+
// Verify the channel uses the expected transport
97+
val channelState = secureChannel.getState(false)
98+
assertThat(channelState).isNotNull()
99+
100+
// Clean up channels
101+
secureChannel.shutdown()
102+
103+
// Verify channels can be shutdown properly
104+
assertThat(secureChannel.awaitTermination(5, TimeUnit.SECONDS)).isTrue()
105+
}
106+
80107
@Test
81108
@Disabled
82109
fun `test queryUtxos`() =

0 commit comments

Comments
 (0)