C# .net integration getting error Failed to create session

Options
dndoanh
dndoanh Member Posts: 3

I follow the instruction in this tutorial:
https://solace.com/samples/solace-samples-dotnet/publish-subscribe/
Getting error (SOLCLIENT_FAIL - Failed to create session) when create session and connect
how to reproduce:

  • Create Solace Cloud free plan
  • Pub/Sub using Secured SMF URI with (host, vpn, username, password)

Please help
Thanks

Tagged:

Comments

  • arih
    arih Member, Employee Posts: 125 Solace Employee
    edited December 2020 #2
    Options

    Hi @dndoanh
    I believe the tutorial didn't include that we need to have a trust store to connect to secured ports. I'm guessing the error is because of something like this: failed to load trust store: unspecified property 'SESSION_SSL_TRUST_STORE_DIR'
    probably something like this:

    If you don't need secured SMF, you can enable plain text ports during the creation of the Solace Cloud brokers like below:

  • dndoanh
    dndoanh Member Posts: 3
    Options

    @arih thanks for your support
    plain text ports working as you said
    secured SMF Host still not working as getting error as bellow
    SSL error: 'wrong version number'(0x1408f10b) in connect for session '(c0,s1)_schoolber-messaging', connection 'client name 'NEXGEESERVER/11408/#00000001/xD2QfEursa', VPN name 'schoolber-messaging', peer host 'tcps://mr-16jp1pl8hgc5.messaging.solace.cloud

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

    Hmm I am not familiar with the error. But no harm to double check the ports and properties are all correct. I remember seeing something about version not correct when I used the wrong port once :)

  • TomF
    TomF Member, Employee Posts: 408 Solace Employee
    Options

    @dndoanh I think @arih is on to something. Could you check your host parameters are using port 55003, and NOT 55555 (the default)?

  • Poornima
    Poornima Member Posts: 25
    Options

    @dndoanh - Did you sorted out the issue. i am facing the same issues. i dont want to go for plain text ports.

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

    Hi @Poornima & @dndoanh,
    I just wanted to follow-up and see if you were able to resolve your issues. If so can you please share what the solution was :)

    thanks!

  • dndoanh
    dndoanh Member Posts: 3
    Options

    @Poornima @marc I haven't resolved this issue yet, it's only working with plain text port 55003, secured port not working

  • Poornima
    Poornima Member Posts: 25
    Options

    @marc @dndoanh I have not resolved this yet

  • TomF
    TomF Member, Employee Posts: 408 Solace Employee
    Options

    @Poornima, I made a mistake in my reply. The SSL port is 55443, NOT 55003 as I had earlier, which is the compressed port.

  • Frankee787
    Frankee787 Member Posts: 10
    edited May 2022 #11
    Options

    Hello,

    I too stumbled on this issue and got the resolved with a suggestion provided by @alamkhan786 . Hoping this well help someone in the future

    1st option and disable complete chain verification

     // Create session properties

          SessionProperties sessionProps = new SessionProperties()

          {

            Host = host,

            VPNName = VPNName,

            UserName = UserName,

            Password = Password,

            ReconnectRetries = DefaultReconnectRetries,

            SSLValidateCertificate = false

          };

    2nd Option - Load the store which has the Trusted CA public certificate

          X509CertificateCollection certificatesCollection = new X509CertificateCollection();

          foreach (StoreLocation storeLocation in (StoreLocation[])Enum.GetValues(typeof(StoreLocation)))

          {

            foreach (StoreName storeName in (StoreName[]) Enum.GetValues(typeof(StoreName)))

            {

              X509Store store = new X509Store(storeName, storeLocation);

              try

              {

                store.Open(OpenFlags.OpenExistingOnly);

                foreach (X509Certificate certificate in store.Certificates)

                {

                  certificatesCollection.Add(certificate);

                }

               

              }

              catch (CryptographicException)

              {

                Console.WriteLine("No      {0}, {1}",  store.Name, store.Location);

              }

            }

            Console.WriteLine();

          }


    Use it during the setup of SessionProperties

       SessionProperties sessionProps = new SessionProperties()

          {

            Host = host,

            VPNName = VPNName,

            UserName = UserName,

            Password = Password,

            ReconnectRetries = DefaultReconnectRetries,

            SSLTrustStore= certificatesCollection 

          };


    Hope it will help the community.

    Best Regards,

    Franklin

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

    Thank you so much for sharing @Frankee787