连接被拒绝[Tarantool + java客户端]

时间:2017-09-03 18:05:14

标签: java sockets docker kotlin tarantool

当我试图连接到tarantool服务器时,我收到以下错误:

  

线程中的异常" main" java.net.ConnectException:连接   拒绝:连接java.net.DualStackPlainSocketImpl.connect0(原生   方法)at   java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)     在   java.net.AbstractPlainSocketImpl.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   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)) // <- error
                }
                else -> {
                    p1.printStackTrace(System.out)
                    null!!
                }
            }
        }

        client = TarantoolClientImpl(socketChannelProvider, config)
    }
}

fun main(args: Array<String>): Unit {    
    val client: Tarantool = Tarantool()
    println(client.client.isAlive)
}

当我试图使用不同的ip

时,我得到同样的错误

与此处的教程相同:https://github.com/tarantool/tarantool-java/

我还使用以下命令创建了测试用户:

box.schema.user.create('test', { password = 'test' })
box.schema.user.grant('test', 'execute,read,write', 'universe')

我使用docker for tarantool,我试图从Windows 7 cmd ping IP并运行。

谢谢!

解决

0 个答案:

没有答案