0
votes

An error Invalid Session ID is occuring on Mule an a application that use SOAP with SugarCRM Connector (http://mulesoft.github.io/sugarcrm-connector/).

But this error occur in this scenario:

  1. App starts and process all Poll (database query)
  2. SOAP works fine
  3. The App stays waiting a new update/insert
  4. After of a time (24 hours, p.e) a new update/insert occurs
  5. The flow is processed in the App
  6. But, the following error occurs (repreat for ever):

EDIT:

2016-03-24 12:31:30,470 [pool-106-thread-1] ERROR org.mule.retry.notifiers.ConnectNotifier - Failed to connect/reconnect: Work Descriptor. Root Exception was: Invalid Session ID. Type: class org.apache.cxf.binding.soap.SoapFault 2016-03-24 12:31:30,471 [pool-106-thread-1] ERROR org.mule.exception.DefaultMessagingExceptionStrategy - ******************************************************************************** Message : Failed to invoke getEntryList. Message payload is of type: GetEntryListRequest Code : MULE_ERROR-29999 -------------------------------------------------------------------------------- Exception stack is: 1. Invalid Session ID (org.apache.cxf.binding.soap.SoapFault) org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor:84 (null) 2. Invalid Session ID (javax.xml.ws.soap.SOAPFaultException) org.apache.cxf.jaxws.JaxWsClientProxy:158 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/xml/ws/soap/SOAPFaultException.html) 3. Failed to invoke getEntryList. Message payload is of type: GetEntryListRequest (org.mule.api.MessagingException)
org.mule.devkit.processor.DevkitBasedMessageProcessor:133 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html) -------------------------------------------------------------------------------- Root Exception stack trace: org.apache.cxf.binding.soap.SoapFault: Invalid Session ID at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:84) at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:51) at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:40) + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)


2016-03-24 12:31:40,471 [pool-106-thread-1] ERROR org.mule.retry.notifiers.ConnectNotifier - Failed to connect/reconnect: Work Descriptor. Root Exception was: Invalid Session ID. Type: class org.apache.cxf.binding.soap.SoapFault 2016-03-24 12:31:40,472 [pool-106-thread-1] ERROR org.mule.exception.DefaultMessagingExceptionStrategy - ******************************************************************************** Message : Failed to invoke getEntryList. Message payload is of type: GetEntryListRequest Code : MULE_ERROR-29999 -------------------------------------------------------------------------------- Exception stack is: 1. Invalid Session ID (org.apache.cxf.binding.soap.SoapFault) org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor:84 (null) 2. Invalid Session ID (javax.xml.ws.soap.SOAPFaultException) org.apache.cxf.jaxws.JaxWsClientProxy:158 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/xml/ws/soap/SOAPFaultException.html) 3. Failed to invoke getEntryList. Message payload is of type: GetEntryListRequest (org.mule.api.MessagingException)
org.mule.devkit.processor.DevkitBasedMessageProcessor:133 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html) -------------------------------------------------------------------------------- Root Exception stack trace: org.apache.cxf.binding.soap.SoapFault: Invalid Session ID at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:84) at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:51) at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:40) + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)


I configured reconnection accord the image below, but does not error continues.

enter image description here

EDIT:

XML Configuration (simplified)

<db:oracle-config name="Oracle_Configuration" host="${db.host}" port="${db.port}" instance="${db.instance}" user="${db.user}" password="${db.password}" doc:name="Oracle Configuration">
    <db:pooling-profile/>
</db:oracle-config>
<sugar:config name="Sugar__Configuration" username="${crm.ws.user}" password="${crm.ws.password}" endpoint="${crm.ws.endpoint}" doc:name="Sugar: Configuration">
    <sugar:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW"/>
    <reconnect-forever frequency="60000"/>
</sugar:config>    
<flow name="produto-precoFlow" processingStrategy="synchronous">
    <poll doc:name="Poll" doc:description="Produto">
        <fixed-frequency-scheduler frequency="10000"/>
        <watermark variable="carimboTempo" default-expression="2016-02-24 00:00:00" selector="MAX" selector-expression="#[message.payload.datalt]"/>
        <db:select config-ref="Oracle_Configuration" doc:name="Database">
            <db:parameterized-query><![CDATA[SELECT * FROM PRODUTO WHERE TO_CHAR(DATALT, 'yyyy-mm-dd hh24:mi:ss') > #[flowVars.carimboTempo]]]></db:parameterized-query>
        </db:select>
    </poll>
    <foreach doc:name="For Each">
        <enricher target="#[payload.produtoPrecoSugar]" doc:name="Message Enricher Produto">
            <flow-ref name="produto-precoSub_FlowProduto" doc:name="produto-precoSub_FlowProduto"/>
        </enricher>
         // [...] mode code here (original) 
        <scripting:component doc:name="Groovy Inserir/Alterar">
            <scripting:script engine="Groovy"><![CDATA[import org.mule.modules.sugarcrm.request.SetEntryRequest;
import com.sugarcrm.sugarcrm.NameValue;
req = new SetEntryRequest();
req.setModuleName("AOS_Products");
nameValues = [];
for ( e in message.payload ) {
   nameValue = new NameValue();
   nameValue.setName(e.key);
   nameValue.setValue(e.value.toString());
   nameValues.add(nameValue);        
}
req.setNameValueList(nameValues);
return req;]]></scripting:script>
        </scripting:component>
        <sugar:set-entry config-ref="Sugar__Configuration" doc:name="Sugar Inserir/Alterar"/>
    </foreach>
</flow>
<sub-flow name="produto-precoSub_FlowProduto">
    <scripting:component doc:name="Groovy Id Produto">
        <scripting:script engine="Groovy"><![CDATA[import org.mule.modules.sugarcrm.request.GetEntryListRequest;

req = new GetEntryListRequest();
req.setModuleName("AOS_Products");

whereQuery = "aos_products.deleted = 0";

for ( e in message.payload ) {
    if (e.key == "sapiens_codtpr_c" || e.key == "sapiens_datini_c" || e.key == "sapiens_codser_c")  {
       whereQuery = whereQuery + " and " + e.key + " = '" + e.value.toString() + "'";
    } else if (e.key == "sapiens_codemp_c" || e.key == "sapiens_qtdmax_c") {
       whereQuery = whereQuery + " and " + e.key + " = " + e.value.toString();     
    } 
}

req.setQuery(whereQuery);
req.setSelectFields(["id"]);
req.setDeleted(0);

return req;

]]></scripting:script>
    </scripting:component>
    <sugar:get-entry-list config-ref="Sugar__Configuration" doc:name="Sugar Id Produto e Preço"/>
</sub-flow>

What could be ocurring? Is there a form to resolve this problem?

1
Is it possible that the session ID has expired? How did you get it in the first place?David Dossot
The session on the server may have expired (by timeout), yes. But in this case, Mule should reconnect again, right (reconnection strategy)? The first time, the connection has been made by the Mule server when started/first request, through the Sugar Connection parameters. Edited above to include the XML Configuration.Muka

1 Answers

0
votes

Looking at the source code of the connector, we can see that the Sugar connection is considered valid just by the mere presence of a session ID:

@ValidateConnection
public boolean isConnected() {
    return sessionId != null;
}

This means that even if the session is expired, the connection will be considered active. This could be considered a bug and reported to MuleSoft.

Note that with the reconnection strategy in place, the expected behaviour would be:

  • an outbound operation is attempted,
  • it fails,
  • the reconnection strategy calls connect,
  • the outbound operation is retried and now succeeds. This retry should be done by the application, as part of a reliability pattern.

If you do not observe this behaviour, i.e. if the reconnection strategy doesn't kick in after the failed outbound operation, this is probably a bug that needs reporting to MuleSoft.