安慰消息 - 无法通过nodejs

时间:2015-08-22 16:12:39

标签: node.js message-queue messaging solace-mq solace

我试图从nodejs连接到我们组织中安装的安慰设备。我采用了与solace web messaging demo相同的代码。如以下示例中所示,是session属性:

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

当我调试solace.SessionEventCBInfo的回调方法solace.SolclientFactory.createSession的代码时,我发现以下条件永远不会满足:

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

控件进入所有3种传输方案(HTTP_BASIC,HTTP_BASE64和HTTP_STREAMING)的连接状态,最后进入错误状态。

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

Solace设备有任何配置问题吗?是否应该在配置时在Solace设备上启用Web消息传递?或者我在代码中做错了什么?

更新

请在下面找到session活动的详细信息:

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!!!!!

1 个答案:

答案 0 :(得分:1)

API的断开原因可以为我们提供有关连接失败原因的更多信息。

请您在会话事件回调开始时打印出事件吗?

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

我希望看到类似以下内容。

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)

在我的示例中,无法从运行nodejs的服务器联系Solace设备。这可以从EHOSTUNREACH错误代码中找出。

请注意,需要在Solace设备上执行以下配置以启用Web消息传递。

  1. 需要在设备上安装许可证密钥才能启用Web消息传递。您可以通过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
    

    请注意&#34; WEB传输服务&#34;是网络消息传递所必需的。

  2. 需要启用Web传输服务。

    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. 验证用于Web传输的端口。默认值为80,可以通过查看WEB服务通过show 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 - - -