Using Proxy setting to connect to Event Broker

Options
anandhanur
anandhanur Member Posts: 3

I am using Java Client code to connect to event broker and need to know how to do Proxy setting in the code.

Tried below code for HOST but its not recognizing the below fromat and throwing "Too many colons in host" exception

tcps:solace.company.com%socks5://User:PassWord@proxy.company.com:13128

Best Answer

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 921 admin
    #2 Answer ✓
    Options

    Correct @anandhanur, I was actually just navigating back to this thread in case others come across it. Per the docs

    The use of proxies is supported by the Java RTO, C, and .NET messaging APIs, but not by JCSMP.


Answers

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

    Hey @anandhanur - I am not sure i understand your question correctly, what exactly do you mean by proxy setting? And what are you trying to do with this (or what is your use case?)

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 921 admin
    Options

    Hi @anandhanur,

    Your host looks correct to me per the docs. Which solace library are you using? Java, Java(JCSMP) or JMS?


    @Tamimi check out "Connecting to Host Event Broker Through Proxies" on this docs page

  • anandhanur
    anandhanur Member Posts: 3
    Options

    Hi @Tamimi - Thank you for the quick reply!

    i have created Event broker and want to publish some events .So I am using JCSMP API to write client EventPublisher code.With the sample code from solace website i am able to run and publish events from my local system which is cloud VDI.Now when i try to run this in onprem machine or machine which doesn't have internet connection,i am getting below error

    "Exception in thread "main" com.solace.messaging.PubSubPlusClientException$ServiceUnreachableException: Service can't be reached using provided host and port"

    So how to resolve this issue.

    Can i set proxy server as part of the HOST configuration ( [Protocol:]Host[:Port][%ProxyService] ) as mentioned in Session Properties Required to Establish a Connection (solace.com) .

    • tcps:solace.company.com%socks5://User:PassWord@proxy.company.com:13128—connect to an event broker at solace.company.com using SSL over TCP through a SOCKS5 proxy server at proxy.company.com, port 13128. Authenticate with the proxy server using username User and password PassWord.

    Doing so i am getting "Too many colons in host" exception.So JCSMP API doesnt not accept the above HOST format.Any leads is much appreciated!

    Meanwhile i am trying with JavaRTO API now..

  • anandhanur
    anandhanur Member Posts: 3
    Options

    Hi @marc -

    I was trying with Java JCSMP API but document says proxy setting is supported only in Java RTO API so i am trying that now..If any fix or work around available for JCSMP is very useful as our team is more inclined towards using JCSMP API.

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 921 admin
    #7 Answer ✓
    Options

    Correct @anandhanur, I was actually just navigating back to this thread in case others come across it. Per the docs

    The use of proxies is supported by the Java RTO, C, and .NET messaging APIs, but not by JCSMP.


  • Shambhu
    Shambhu Member Posts: 4
    Options

    @marc session creation is failing while being in company VPN. so tried with proxy settings as well given in https://docs.solace.com/API/API-Developer-Guide/Session-Props-Required.htm#Creating_ent_sessions_sess_props_host_dir_con but no luck. I tried with multiple debug.

    string host = $"tcp://mr-connection-l7ua5omxxxx.messaging.solace.cloud:55555%httpc://rb-proxy-de.bosch.com:8080";
    string username = "solace-cloud-client";
    string vpnname = "solace1sttryout";
    string password = "pflxxxxxxxxxxxxxxxxxxxqp";

          SessionProperties sessionProps = new SessionProperties()
    {
    Host = host,
    VPNName = VPNName,
    UserName = UserName,
    Password = Password,
    ReconnectRetries = DefaultReconnectRetries,
    SSLValidateCertificate = false,
    //SSLClientCertificateFile = sslFile
    };


    // Connect to the Solace messaging router
    Console.WriteLine("Connecting as {0}@{1} on {2}...", UserName, VPNName, host);
    using (ISession session = context.CreateSession(sessionProps, null, null))
    {
    ReturnCode returnCode = session.Connect();
    if (returnCode == ReturnCode.SOLCLIENT_OK)
    {
    Console.WriteLine("Session successfully connected.");
    PublishMessage(session);
    }
    else
    {
    Console.WriteLine("Error connecting, return code: {0}", returnCode);
    }
    }

    tried with without proxy and with proxy both failed.

    also tried but no luck.

    string host = $"tcps://mr-connection-l7ua5omxxxx.messaging.solace.cloud:55433%httpc://rb-proxy-de.bosch.com:8080";

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 921 admin
    Options

    Hi @Shambhu,

    I don't have a handy proxy to test this out myself, do you mind opening a support ticket and they can help you out?

  • bindu
    bindu Member Posts: 1
    Options

    Hi @Tamimi we are having usecases wherein we are trying to connect with Java JCSMP API to connect to proxy but document says proxy setting is supported only in Java RTO API .If any fix or work around available for JCSMP is very useful do we have any update on if this is considered in your road map