0

我试图从nodejs. 我采用了与 solace web 消息演示中给出的相同的代码。如下例所示是session属性:

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

当我调试 的回调方法的代码时solace.SessionEventCBInfosolace.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!!!!!
4

1 回答 1

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 Appliance 上进行以下配置才能启用 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
    

    请注意,Web 消息传递需要“WEB 传输服务”。

  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,可通过 show service 命令查找 WEB 服务进行验证。

    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 - - -
    
于 2015-08-25T03:00:43.930 回答