Skip to Content

UnknownHostException when connecting to an on-prem system through Cloud Connector from SCP

Hi,

I am trying to connect to an on-prem TCP server from my trial SCP account using Java. I have installed and configured Cloud Connector (version 2.10.2) on my local machine.

From CC I can successfully connect to the TCP server. From my trial account also connectivity test for the destination created for this TCP server through CC is getting passed.

I have followed the steps given in documentation here. Java runtime is Java EE 6 Web Profile.

Though I am able to connect to another on-prem HTTP server through CC without any issue. The connection to the TCP server is failing throwing an UnknownHostException.

To use the socket proxy I also looked into Java documentation here.

Tried using both virtual host and port as well as the actual host and port in the Java code but to no avail. Every time I see the UnknownHostException in the default trace.

I am not sure what is it that I am doing wrong. Any tips / hints will be very helpful.

Regards,

Saurabh Agarwal

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Feb 20 at 10:24 PM

    Hi Saurabh

    Reading your code more closely, I see what is probably the problem: Here you create a socket which uses the SOCKS5 proxy:

    Socket proxySocket = new Socket(proxy);

    However, you then proceed to create a new socket, which does not use the proxy:

    Socket client = new Socket("virtual.host", 8765);

    To actually use the socket with the proxy, do this instead:

    Socket proxySocket = new Socket(proxy);
    proxySocket.connect(new InetSocketAddress("virtual.host", 8765));

    Regards,

    Morten

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 20 at 10:22 AM

    Hi Saurabh

    You always need to use the virtual host and port. It would be helpful of you could post the relevant parts of your Java code, i.e. the parts where you create the Proxy object and use that object to actually make a connection.

    Regards,

    Morten

    Add comment
    10|10000 characters needed characters exceeded

    • Hello again. Solve one problem at a time: Hardcode the subaccount name and location ID until the code works, then work on retrieving the subaccount name dynamically.

      Regards,

      Morten

  • Feb 20 at 02:09 PM

    Hi Saurabh,

    SOCKS proxy is running on every SCP account. Thus, you must connect to this SOCKS5 proxy and perform authentication against it first. Here you will always use localhost and port 20004. Once this is done all request to your virtual address and port (TCP config stored on Cloud Connector's access control) will be done via TCP SOCKS proxy, just as if you were connecting to a local resource. Check the java source code here as refference. Chekc this blog on "How to set up a JDBC Connection using the Cloud Connector". This blog shows you how to connect to a database via JDBC, but you could adapt it perfectly to any TCP service as well.

    Regards,
    Ivan

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Ivan,

      Thank you for your help. I followed the JDBC code and found MySQL connector is also using the same approach to connect to TCP sockets via proxy. It was very helpful.

      Regards,

      Saurabh Agarwal