2013-07-19 43 views
4

我有一個HTTP適配器連接到另一個應用程序以檢索要在移動設備上顯示的數據的Worklight應用程序(使用Android 4.0.4進行測試在這一刻)。IBM Worklight 6.0 - 「從客戶端接收到錯誤令牌」錯誤頻繁發生

當應用程序啓動時,我從我的HTTP適配器調用三個過程,並顯示所有三個過程的結果。

當我在瀏覽器中運行我的應用程序並將其預覽爲Common時,一切正常。
當我在實際的手機上運行應用程序時,會發生該問題。大多數情況下,我的過程調用中的1或2個失敗,數據不顯示,但似乎其中一個(第一個)總能工作。在罕見的情況下,所有3個程序調用都會檢索數據,但我無法一致地重現這種情況。

當一個過程失敗,我收到一個錯誤的工作燈開發服務器控制檯:

[ERROR ] FWLSE4007E: Received bad token from client. Server token:'null', client token:'b3fuqgdid2701hu855n89pldpk'. [project trunk]

有時候,我收到此錯誤,而不是,但它是更常見:

[ERROR ] FWLSE0203E: Received bad instance Id from client. Server instance Id:'3f9eveddc7br5mq3ll0nq89miu', client instance Id:'ut5m5f01i3bkq5l78m54uq137o'. [project trunk]

應用程序始終嘗試WL.Client.invoke處理所有過程,並且當調用成功時,我的onSuccess函數將運行,但是當其他過程失敗時加載他們的數據,onFailure函數永遠不會發生。

我的適配器是這樣的:你調用適配器程序

  • 允許某些延遲

    <displayName>Adapter</displayName> 
    <description>Adapter</description> 
    <connectivity> 
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType"> 
         <protocol>http</protocol> 
         <domain>10.50.22.161</domain> 
         <port>9000</port> 
        </connectionPolicy> 
        <loadConstraints maxConcurrentConnectionsPerNode="5"/> 
    </connectivity> 
    
    <procedure name="getProcesses" securityTest="securityTest" /> 
    <procedure name="getTasks" securityTest="securityTest" /> 
    <procedure name="metricsList" securityTest="securityTest" /> 
    <procedure name="getMetric" securityTest="securityTest" /> 
    <procedure name="getAllHashTags" securityTest="securityTest" /> 
    <procedure name="getMessages" securityTest="securityTest" /> 
    <procedure name="getMentions" securityTest="securityTest" /> 
    <procedure name="getConversations" securityTest="securityTest" /> 
    <procedure name="getServerTime" securityTest="securityTest" /> 
    

    When I remove the securityTests from the procedures, the error seems to occur less frequently, but still occurs.

    What is the problem here? Or how can I debug the Worklight Server in order to determine the cause?

    I am using the Eclipse Worklight plug-in with version 6.0.0.20130701-1413.

  • 回答

    2

    This sounds very similar to a race condition defect identified not too long ago.

    Several possible workarounds:

    1. Make sure to WL.Client.connect以前在應用程序啓動後,然後才調用適配器程序
    2. 你也可以嘗試添加以下內容到JavaScript的:

      wl_noDeviceProvisioningChallengeHandler.handleFailure = function() { 
          WL.Client.connect(); 
      }; 
      
    3. 與上述相同3,但WL.Client.reloadApp()

    問:在initOptions.js,是否設置connectOnStartup爲 「真」 或 「假」?

    +0

    感謝您的回覆。我嘗試了第二種解決方案,但它不起作用,但這裏是我發現的: - 當所有3個過程成功時,該方法未被調用(顯然)爲 - 在某些情況下,該方法僅被調用一次,看似成功,但我的數據仍然沒有完全加載 - 在其他一些場景中,該方法被調用了3次,第二個和第三個「在執行時無法調用WL.Client.connect」。嘗試連接時出錯。我在連接周圍添加了一個!WL.Client.isConnected(),但它沒有幫助。 我會盡量延遲,謝謝。 –

    +0

    我試過在我的所有程序調用之前放了10秒的延遲,但它也沒有工作。 –

    +0

    爲什麼一個應用程序連接到另一個應用程序來檢索數據?適配器如何發揮作用呢?適配器通過工作燈服務器請求數據。 –

    1

    在調用過程之前,您必須調用WL.Client.connect()並等待其成功回調。

    +0

    我在6.1.0.2版本的worklight上看到此問題,請確認它是否也發生在此版本上。 – Max

    相關問題