Valay
Valay

Reputation: 1999

solace messaging - not able to connect to solace appliance via nodejs

I was trying to connect to solace appliance installed in our organization from nodejs. I took the same code as given in solace web messaging demo. As given in the example below are the session properties:

my_web_server_url = "http://<ip:port>/smf";
my_client_username = "<username>";
my_vpn = "<vpnname>";
my_password = "<password>";

When I debug the code of a callback method solace.SessionEventCBInfoof solace.SolclientFactory.createSession, I found that below condition never meets:

if (event.sessionEventCode === solace.SessionEventCode.UP_NOTICE) {
   console.log(":::Connected:::");
}  

And the control goes to the connecting state for all 3 transport schemes (HTTP_BASIC, HTTP_BASE64 and HTTP_STREAMING) and finally goes to error condition.

else if (event.sessionEventCode === solace.SessionEventCode.CONNECTING) {
            console.log(":::Connecting.....");
        } else {
            console.log(":::Error!:::");
        }

Is there any configuration issue on solace appliance ? Should web messaging be enabled on solace appliance while configuring ? Or am I doing something wrong in the code ?

Update

Please find below the details of session event:

Session event: sessionEventCode=CONNECTING, infoStr=Establishing connection (transport:HTTP_BINARY_STREAMING), responseCode=, errorSubCode=, correlationKey=, reason=()
(index):105 Connecting.....
(index):102 Session event: sessionEventCode=CONNECTING, infoStr=Establishing connection (transport:HTTP_BINARY), responseCode=, errorSubCode=, correlationKey=, reason=()
(index):105 Connecting.....
(index):102 Session event: sessionEventCode=CONNECTING, infoStr=Establishing connection (transport:HTTP_BASE64), responseCode=, errorSubCode=, correlationKey=, reason=()
(index):105 Connecting.....
(index):102 Session event: sessionEventCode=DISCONNECTED, infoStr=Session is destroyed, responseCode=, errorSubCode=, correlationKey=, reason=(Transport session event: sessionEventCode=2, infoStr=Session is destroyed, responseCode=, sid=)
(index):109 Error!!!!!

Upvotes: 0

Views: 1402

Answers (1)

Russell Sim
Russell Sim

Reputation: 1733

The disconnect reason from the API would be able to provide us with more information as to why the connection is failing.

Would you please print out the events right at the start of the session event callback?

new solace.SessionEventCBInfo(function(session, event) {
    console.log(event.toString());
    // The rest of your connection logic below
}

I would expect to see something similar to the following.

Session event: sessionEventCode=CONNECTING, infoStr=Establishing connection (transport:HTTP_BINARY_STREAMING), responseCode=, errorSubCode=, correlationKey=, reason=()
Session event: sessionEventCode=CONNECTING, infoStr=Establishing connection (transport:HTTP_BINARY), responseCode=, errorSubCode=, correlationKey=, reason=()
Session event: sessionEventCode=CONNECTING, infoStr=Establishing connection (transport:HTTP_BASE64), responseCode=, errorSubCode=, correlationKey=, reason=()
Session event: sessionEventCode=DISCONNECTED, infoStr=Connection create failure: HTTP request failed: status=503 statusText=Error: connect EHOSTUNREACH, responseText length=143, XHR errorCode=EHOSTUNREACH, responseCode=, errorSubCode=44, correlationKey=, reason=(Transport session event: sessionEventCode=2, infoStr=Connection create failure: HTTP request failed: status=503 statusText=Error: connect EHOSTUNREACH, responseText length=143, XHR errorCode=EHOSTUNREACH, responseCode=44, sid=N/A)

In my example, the Solace appliance cannot be contacted from my server running nodejs. This can be figured out from the EHOSTUNREACH error code.

Do note that the following configuration needs to be done on the Solace Appliance to enable web messaging.

  1. A license key needs to be installed on the appliance to enable web messaging. You can verify this via the following command from the CLI.

    solace1> show product-key
    
    Product Key : H1mqWPKYjgQ-7JiNX6d2k1M-Tg9Ezd5a7WA-CACHE:WEB:GM450K:OMAMA-C-S009000149
      Unlocked Features : 4
        SolCache
        WEB Transport Service
        Guaranteed Messaging 450k
        OpenMAMA
    

    Note that the "WEB Transport Service" is required for web messaging.

  2. The Web-Transport service needs to be enabled.

    solace1> show service
    
    Msg-Backbone:       Enabled
      SMF:              Enabled
        Web-Transport:  Enabled
      REST Incoming:    Shutdown
      REST Outgoing:    Shutdown
    
    Max Incoming Connections:       9000
      Service SMF:                  9000
      Service Web-Transport:        9000
      Service REST:                 9000
    Max Outgoing Connections:
      Service REST:                 6000
    Max SSL Connections:            9000 
    
  3. Verify that the port that is used for web transport. The default is 80, and can be verified via the show service command by looking for the WEB service.

    solace1> show service
        ---- truncated output ----
                                          Status
    Service  VRF   MsgVpn          Port  A O S C R Failed Reason
    -------- ----- --------------- ----- --------- ---------------------------
    SEMP     Mgmt                     80 U U N - -
    SEMP     Mgmt                    443 U D Y - - No Cert
    SMF      MsgBB                 55555 U U N N N
    SMF      MsgBB                 55003 U U N Y N
    SMF      MsgBB                 55556 U D N N Y
    SMF      MsgBB                 55443 U D Y N N No Cert
    WEB      MsgBB                    80 U U - - -
    

Upvotes: 1

Related Questions