Local ( docker to Local solace connection failure.

Options

Kindly help. @marc @JamilAhmed @Neha

I am getting the connection failure error when i tried to connect
from Local Docker ( simple application Spring cloud - Function Processor) to solace Localhost.

I checked the /etc/hosts in my Mac and see that it is correctly mapped for localhost.

Please note that before deploying to docker, same application works fine in my eclipse as spring boot app.

Error details:

021-09-07 03:20:56.969 INFO 1 --- [ main] c.s.j.protocol.impl.TcpClientChannel : Connection attempt failed to host 'localhost' ConnectException com.solacesystems.jcsmp.JCSMPTransportException: (Client name: e6f94322ff6a/1/#00120001/CBzOqDQrGK Local port: -1 Remote addr: localhost Remote port: 55555) - Error communicating with the router. cause: java.net.ConnectException: Connection refused ((Client name: e6f94322ff6a/1/#00120001/CBzOqDQrGK Local port: -1 Remote addr: localhost Remote port: 55555) - )
2021-09-07 03:20:59.971 INFO 1 --- [ main] c.s.j.protocol.impl.TcpClientChannel : Connecting to host 'orig=localhost, host=localhost' (host 1 of 1, smfclient 1, attempt 1 of 1, this_host_attempt: 13 o

Comments

  • arih
    arih Member, Employee Posts: 125 Solace Employee
    Options

    Hi @balajirengarajan

    If your app is inside a docker container and your Solace event broker are running locally, then you can't use localhost to access the broker from within your container. Localhost simply refers to the container itself, not your laptop/host. When the app is running locally via IDE or via command line as Spring boot app, the app is able to access the broker since the broker container should have exposed the ports to your local OS (the -p 55555:55555 in your docker run command).

    Now I assume your Solace broker is also deployed as a docker container. I would use the same network for both container so they can access each other simply using their container name. I did exactly that in one of my demo repo here: https://github.com/arih1299/rest-vs-smf-docker

    If you already have your broker container running, you can use docker network connect command to attach it. So, here's how I'd do it:

    First, create the network:
    docker network create solace-net

    Second, attach my broker container to that network:
    docker network connect <mysolacecontainername> solace-net

    Third, either use --network solace-net when running the app container, or just attach it like we did with the solace broker container.

  • balajirengarajan
    balajirengarajan Member Posts: 2
    Options

    Thank you @arih for your support.

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 491 admin
    Options

    Hey @balajirengarajan! did this resolve your issue?