kafka连接:restapi源连接器连接被拒绝

4si2a6ki  于 2021-06-04  发布在  Kafka
关注(0)|答案(0)|浏览(271)

我是新的Kafka连接api。我创建了一个restapi源连接器,它可以很好地用于api端点,例如http://codeforces.com/api/user.rating?handle=tourist 但每当我尝试访问本地spring引导服务器api端点时,kafka日志中就会出现一个错误,表示连接被拒绝。
我在用docker的图片制作zookeeper,kafka和kafka connect
我的服务器的端点如下所示。

@CrossOrigin(origins = "*")
    @GetMapping(path="/1")
    public String getCall1() {
        String tmp = "{\n"
                + "id: 1;\n"
                + "}\n";
        return tmp;
    }

    @CrossOrigin(origins = "*")
    @GetMapping(path="/2")
    public String getCall2() {
        String tmp = "{\n"
                + "id: 2;\n"
                + "}\n";
        return tmp;
    }

在我得到的错误之后

connect      | java.net.ConnectException: Connection refused (Connection refused)
connect      |  at java.net.PlainSocketImpl.socketConnect(Native Method)
connect      |  at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
connect      |  at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
connect      |  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
connect      |  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
connect      |  at java.net.Socket.connect(Socket.java:589)
connect      |  at java.net.Socket.connect(Socket.java:538)
connect      |  at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
connect      |  at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
connect      |  at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
connect      |  at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
connect      |  at sun.net.www.http.HttpClient.New(HttpClient.java:339)
connect      |  at sun.net.www.http.HttpClient.New(HttpClient.java:357)
connect      |  at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
connect      |  at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
connect      |  at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
connect      |  at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
connect      |  at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
connect      |  at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
connect      |  at java.net.URL.openStream(URL.java:1045)
connect      |  at com.example.demo.SampleSourceTask.getUrlContents(SampleSourceTask.java:93)
connect      |  at com.example.demo.SampleSourceTask.lambda$poll$2(SampleSourceTask.java:72)
connect      |  at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
connect      |  at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
connect      |  at com.example.demo.SampleSourceTask.poll(SampleSourceTask.java:64)
connect      |  at org.apache.kafka.connect.runtime.WorkerSourceTask.poll(WorkerSourceTask.java:270)
connect      |  at org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:237)
connect      |  at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:184)
connect      |  at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:234)
connect      |  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
connect      |  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
connect      |  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
connect      |  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
connect      |  at java.lang.Thread.run(Thread.java:748)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题