IBM Worklight 6.0.0.1 - Push notifications polling not working in Production environment

孤街浪徒 提交于 2019-12-02 09:01:38

问题


My problem is this:

  • When in Development environment, everything is OK - the poller is working fine, the DB statuses changes, etc.

  • When in Production environment, nothing appears in the log and nothing changes in the DB (I'm reading notifications from a DB table).


Push Notifications eventSource:

WL.Server.createEventSource({
    name : 'PushEventSource',
    poll : { 
        interval : 360, 
        onPoll : 'sendNotifications' 
    },
    securityTest : 'mobileSecTest' 
});


mobileSecTest security test:

<mobileSecurityTest name="mobileSecTest"> 
    <testUser realm="LdapAdapterRealm"/>
    <testDeviceId provisioningType="none"/>
</mobileSecurityTest>


sendNotifications() implementation:

var notificationServicesResourceName = "PushAdapter";
function sendNotifications(){

WL.Logger.info('Starting to send notifications');
    var lockInvocationData = {
            adapter : "SQLConnector",
            procedure : "isLocked",
            parameters : [ notificationServicesResourceName ]
    };
    var isLockedResult = WL.Server.invokeProcedure(lockInvocationData);
    if (!isLockedResult.locked) {
        lockInvocationData = {
                adapter : "SQLConnector",
                procedure : "acquireLock",
                parameters : [ notificationServicesResourceName ]
        };
        WL.Server.invokeProcedure(lockInvocationData);

//Get the list of all notifications, from external database
        var dbResponse = getAllUnsentNotifications();

        var data = dbResponse.data ;

        /////////////////THE REST OF THE LONG LONG CODE ////////////
        //Reealse lock
        lockInvocationData = {
                adapter : "SQLConnector",
                procedure : "releaseLock",
                parameters : [ notificationServicesResourceName ]
        };
        WL.Server.invokeProcedure(lockInvocationData);
    }
}


Adapter XML file:

<wl:adapter name="PushAdapter"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:wl="http://www.worklight.com/integration"
    xmlns:http="http://www.worklight.com/integration/http">

    <displayName>PushAdapter</displayName>
    <description>PushAdapter</description>
    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>http</protocol>
            <domain>${com.ibm.moi.ci.host}</domain>
            <port>${com.ibm.moi.ci.port}</port> 
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="300" />
    </connectivity>
    <!-- Replace this with appropriate procedures -->
    <procedure name="sendNotifications"/>
    <procedure name="submitNotification"/>

</wl:adapter>

回答1:


So I got this running now. It was a security problem. When you run the application on your local workstation on worklight studio and liberty profile, some security features are disabled which is not the case of the production.

On development mode all the procedures with no explicit securityTest have wl_inprotected by default I think they did it like this in order to be able to invoke procedures from Eclipse. In the production environment the security is enhanced and wl_unprotected is not considered as the default security test.

So what I did is to add securityTest="wl_unprotected" for all the procedures in the execution chain except the sendNotifications procedure which should remain without sec test.

That's it !



来源:https://stackoverflow.com/questions/20878780/ibm-worklight-6-0-0-1-push-notifications-polling-not-working-in-production-env

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!