当我尝试连接到tarantool服务器时,我收到以下错误:
线程“main”中的异常java.net.ConnectException:连接被拒绝:在java.net.DualStackPlainSocketImpl.smplConnect(DualStackPlainSocketImpl.java:79)的java.net.AualStackPocketSmplImpl.mpl上连接java.net.DualStackPlainSocketImpl.connect0(连接) .doConnect(AbstractPlainSocketImpl.java:350)java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206),java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188),java.net.PlainSocketImpl.connect(PlainSocketImpl . java:172)at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)at java.net.Socket.connect(Socket.java:589)at java.net.Socket.connect(Socket.java:538)at at java.net.Socket . (Socket.java:434)at java.net.Socket . (Socket.java:211)at TarantoolKt.main(Tarantool.kt:37)
我的代码:
class Tarantool {
val client: TarantoolClient
init {
val config: TarantoolClientConfig = TarantoolClientConfig()
config.apply {
username = "test"
password = "test"
}
val socketChannelProvider: SocketChannelProvider = SocketChannelProvider { _, p1 ->
when(p1) {
null -> {
println("Trying to connect . . .")
SocketChannel.open(InetSocketAddress("192.168.1.254", 3301)) //
}
else -> {
p1.printStackTrace(System.out)
null!!
}
}
}
client = TarantoolClientImpl(socketChannelProvider, config)
}
}
fun main(args: Array): Unit {
val client: Tarantool = Tarantool()
println(client.client.isAlive)
}
当我尝试使用不同的ip时,我得到了同样的错误
我还使用以下命令创建了测试用户:
box.schema.user.create('test', { password = 'test' })
box.schema.user.grant('test', 'execute,read,write', 'universe')
我使用docker for tarantool,我试图从Windows 7 cmd ping IP并且它可以工作 .
谢谢!
SOLVED