My company is trying out Worklight.
A trial WL server is setup inside corporate network.
Devices on the Internet must reach the WL server by going through an external firewall. The firewall accepts connections to 443. Any https traffic coming to this address is reverse proxied to the internal worklight server, let’s call this https://wl.virtual.corp.com:9443
.
The firewall will only proxy connections, if a specific cookie value is set. To try this scenario, we created a very simple one page hello world hybrid worklight app using the DevStudio defaults, that just displays an image.
In wlInitOptions.js connectOnStartup
is set to false
.
In main.js wlCommonInit()
the cookie is set with addGlobalHeader()
, then WL.Client.connect()
is called.
On android all is well – the wl client connects and shows the 1st page.
On iOS neither the connect success nor the connect fail callback is ever invoked.
The iOS log shows an infinite loop requesting the https://…iphone/init
page followed by DeviceAuth – over and over without end until the app is forced down:
2014-06-05 16:15:03.330 Mobilithon[177:60b] [DEBUG] [NONE] Request [https://mobilithon-worklight.corp.com:443/worklight/apps/services/api/Mobilithon/iphone/init]
2014-06-05 16:15:03.612 Mobilithon[177:60b] DeviceAuthManager:getWorklightUniqueDeviceId --> returning UUID from the keychain
2014-06-05 16:15:03.629 Mobilithon[177:60b] THREAD WARNING: ['DeviceAuth'] took '16.558838' ms. Plugin should use a background thread.
2014-06-05 16:15:03.632 Mobilithon[177:60b] [DEBUG] [NONE] Request [https://mobilithon-worklight.corp.com:443/worklight/apps/services/api/Mobilithon/iphone/init]
2014-06-05 16:15:03.818 Mobilithon[177:60b] DeviceAuthManager:getWorklightUniqueDeviceId --> returning UUID from the keychain
2014-06-05 16:15:03.833 Mobilithon[177:60b] THREAD WARNING: ['DeviceAuth'] took '14.851074' ms. Plugin should use a background thread.
2014-06-05 16:15:03.837 Mobilithon[177:60b] [DEBUG] [NONE] Request [https://mobilithon-worklight.corp.com:443/worklight/apps/services/api/Mobilithon/iphone/init]
2014-06-05 16:15:04.022 Mobilithon[177:60b] DeviceAuthManager:getWorklightUniqueDeviceId --> returning UUID from the keychain
2014-06-05 16:15:04.036 Mobilithon[177:60b] THREAD WARNING: ['DeviceAuth'] took '14.554932' ms. Plugin should use a background thread.
2014-06-05 16:15:04.042 Mobilithon[177:60b] [DEBUG] [NONE] Request [https://mobilithon-worklight.corp.com:443/worklight/apps/services/api/Mobilithon/iphone/init]
2014-06-05 16:15:04.236 Mobilithon[177:60b] DeviceAuthManager:getWorklightUniqueDeviceId --> returning UUID from the keychain
2014-06-05 16:15:04.251 Mobilithon[177:60b] THREAD WARNING: ['DeviceAuth'] took '14.396973' ms. Plugin should use a background thread.
2014-06-05 16:15:04.254 Mobilithon[177:60b] [DEBUG] [NONE] Request [https://mobilithon-worklight.corp.com:443/worklight/apps/services/api/Mobilithon/iphone/init]
2014-06-05 16:15:04.397 Mobilithon[177:60b] DeviceAuthManager:getWorklightUniqueDeviceId --> returning UUID from the keychain
2014-06-05 16:15:04.412 Mobilithon[177:60b] THREAD WARNING: ['DeviceAuth'] took '14.641846' ms. Plugin should use a background thread.
2014-06-05 16:15:04.417 Mobilithon[177:60b] [DEBUG] [NONE] Request [https://mobilithon-worklight.corp.com:443/worklight/apps/services/api/Mobilithon/iphone/init]
2014-06-05 16:15:04.632 Mobilithon[177:60b] THREAD WARNING: ['WLApp'] took '12.687988' ms. Plugin should use a background thread.
2014-06-05 16:15:04.644 Mobilithon[177:60b] DeviceAuthManager:getWorklightUniqueDeviceId --> returning UUID from the keychain
2014-06-05 16:15:04.659 Mobilithon[177:60b] THREAD WARNING: ['DeviceAuth'] took '14.371826' ms. Plugin should use a background thread.
2014-06-05 16:15:04.662 Mobilithon[177:60b] [DEBUG] [NONE] Request [https://mobilithon-worklight.corp.com:443/worklight/apps/services/api/Mobilithon/iphone/init
Here are the changes made to the default hybrid app files:
in initOptions.js:
var wlInitOptions = {
…
connectOnStartup : false,
…
}
in index.html:
<!--application UI goes here-->
<img border="0" src="images/mcoe.png">
in main.js:
var busyIndicator;
function wlCommonInit() {
WL.Client.addGlobalHeader("Cookie", "AuthKey=foryoureyesonly");
busyIndicator = new WL.BusyIndicator('',{text : 'Connecting...'});
busyIndicator.show();
WL.Client.connect(
{
onSuccess: onConnectSuccess,
onFailure: onConnectFailure
});
}
var onConnectSuccess = function()
{
// Go!
busyIndicator.hide();
};
var onConnectFailure = function(error)
{
busyIndicator.hide();
if(error==null) error = "No reason given";
alert("Connection to server failed: " + JSON.stringify(error));
}
}