Worklight Client timeout call not getting invoked - ibm-mobilefirst

We are facing an issue with the client timeout where the failure call is not getting invoked.
The issue appears as the following:
The user clicks on Sign in in our application.
After 4sec the user is able to login successfully to the app.
We recycle the Web services server and the user is taking 17sec to get the response back where it times out since we had set our time out to be 10000ms as our client requirements and it stays on the "Sign in" page without showing any error. On the second attempt to "Sign in" to the app, the response is coming in 4 sec and the app acts normally.
In the case of timing out we need to invoke a failure call to the user to inform him that error occurred and time out. but the call is not getting invoked:
initOption.js:
var wlInitOptions = {
.
.
// # Worklight server connection timeout
timeout: 10000,
// # Function to handle failure of Request Timeout
onRequestTimeout : function (error) {
WL.SimpleDialog.show(
"System Error: Request Timeout",
error,
[{text: "Close", handler: null}]
);
},
.
.
};
Worklight version 6.2
Please let me know if extra code sharing is required.
Thanks
Edite:
Application flow:
once the user launch the application it will connect to WL server, the user then will click on sign in button which will trigger and adapter method "Login".
once the login process is done, it will do another call to get user data and fetch them to the device.
As I described, when the user click on Login the app will try to invoke the authentication function from the adapter. we have set the time out for the application to wait for the response back to be 10sec as mentioned in the coed above.
If the application didn't get the response back, then We need to show the user a dialog box with the appropriate text.
The issue is getting resolved if I increased the timeout from 10sec to 30 sec. However, I need to keep the timeout 10 sec and show the user a dialog box on timeout.

The timeout value mentioned in the code is between the client and the server, but there is an additional timeout, between the adapter procedure and the backend; you will want to have these properly synced/aligned/timed.
Are you using requestTimeoutInSeconds in the adapter XML?
Read more here: IBM Worklight 6.0.0.1 - Timeout setting in Adapters

Related

Which event does Feathers Authentication return after authenticating user login

I am learning Feathers. I try to understand which event a server side Feathers Authentication module sends back to the client after it authenticates the user login information injected from the client (the connection is through socket.io).
Here is the background and the set up:
I created a copy of the example 'feathers-chat' app (https://github.com/feathersjs/feathers-chat) in the Guides on https://docs.feathersjs.com. The app works fine. I can login user at localhost:3030 from a browser. In the browser developer tools, I can see the websocket connection established by socket.io. Inside that connection, there are two events after clicking the login button in the browser:
The first event was sent from the browser to the server:
0: "create"
1: "authentication"
2: { strategy: "local", email: "user_email", password: "user_password" }
3: {}
I assume that the event name of this one is "create" and the rest information in 1-3 are event data.
The second event was sent by the server to the browser after login success:
0: null
1: { accessToken: "token...",
authentication: { strategy: "local", accessToken: "token...",payload: {...} },
user: {...}}
My question is: What is the event name of the second event? Is it null?
The reason for this question is that I try to use Postman to send and receive socket.io event data directly to the server during development. Postman needs a name for its event listener. I can send the first "create" event from Postman to the server successfully (the event was captured in the debugger on the server). But I can't figure out how to capture the second return event from the server in Postman. I created a listener called "null" but it doesn't work.

MobileFirst Obtain Access token and Login give no response after setting WL.App.setServerURL

As per my requirement, I am using WL.APP.setServerURL before every login request WLAuthorizationManager.loginof mobilefirst.
When I do first an valid/Invalid login attempt it works fine. As on next attempt I do WL.App.setServerURL, and then WLAuthorizationManager.login (login request) OR WLAuthorizationManager.obtainAccessToken (obtain access token request) don't respond anything. No success and no fail. Although non-secure adapter method works fine.
If I do WL.APP.setServerURL only once on application startup, everything works fine but in between call cause application failure.
let url = ... //fetcht url from adapter call
WL.App.setServerUrl(url, function (sucess) {
WLAuthorizationManager.login(securityCheckName, loginParam).then((data) => {
.... //After login code
}, (response) => {
//Login fail code
});
}, function (error) {
});
Flow :-
I call above code on click of login button.I call a method to get server url from adapter first then I set that url as server url.
When I do an invalid attempt of login it works find for first time, and on next call MFP login, it doesn't respond. Not success nor fail in application.
I am getting error in native logs android.
Android Error logs :-
E/SecurityCheckChallengeHandler(30199): SecurityCheckChallengeHandler.submitChallengeAnswer in SecurityCheckChallengeHandler.java:51 :: submitAnswer has been called for unknown request
.
MobileFirst server version :- 8.0.0.00-20170911-123510
MobileFirst Cordova(plugin) version :- 8.0.2017102403
The WL.App.setServerUrl API is meant to be used sparingly whenever the app needs to connect to a server other than the one defined in mfpclient.properties. If you want to keep the server URL constant, you should just put it up in the mfpclient.properties.
Having said that, the behaviour you mention is not expected - can you update your question with a code snippet of your app performing login & setServerUrl

How do I capture the Worklight defaultOptions:onFailure event?

I have a Worklight 6.1.0.1 hybrid app that I'm running on iOS. The app uses adapter-based authentication. The app prepares the invocation data makes the following call when the Login button is clicked:
singleStepAuthRealmChallengeHandler.submitAdapterAuthentication(invocationData, {});
If the WL service is down, or if the mobile device has no network access, the invocation will timeout. I see the following in the Xcode console:
defaultOptions:onFailure Request timed out for http://myipaddress:10080/myapp/apps/services/../../invoke. Make sure the host address is available to the application (especially relevant for Android and iPhone apps).
How can I capture this timeout event, so that I can update the UI with a proper message?
Update May 23rd based on comments:
What is your exact flow?
You should first use WL.Client.connect({onSuccess: ..., onFailure:...});
If connection to the server is successful, you will enter the challenge handler. Otherwise, you will enter onFailure and there you can create the custom error handling.
Previous answer attempt:
The below is when trying to connect() to the Worklight Server.
If you want custom handling for when the client fails connecting to the server I believe you need to enable and use the option onConnectionFailure in initOptions.js:
var wlInitOptions =
// # The callback function to invoke in case application fails to connect to Worklight Server
//onConnectionFailure: function (){},
}
Otherwise, Worklight's default dialog will be displayed.

Worklight 6.1- What does this logs `wl_antiXSRFRealm challenge handler's waiting list` mean when making a call to adapter

What does this logs meant which is given below when making a call to adapter. This logs we are getting on Xcode console while testing on IOS5,IOS6,IOS7. I noticed that Whenever we make a call to adapter and if it get success this logs never comes in console.
And if we are not getting any failure and success from adapter after making call to adapter, this wl_antiXSRFRealm challenge handler's waiting list logs comes on Xcode console and it stuck over there. Now this time we are not even getting failure and success for adapter call and same logs will remain on Xcode console till we make a another call to adapter.
2014-01-23 16:06:13.953 MyApp[78767:a0b] WLRequestBuilder.initWithRootUrl else_url: https://IPADDRESS:443/MyApp/apps/services/api/MyApp/ipad/0/query
2014-01-23 15:40:45.018 MyApp[78116:a0b] Adding request to wl_antiXSRFRealm challenge handler's waiting list
2014-01-23 15:40:45.018 MyApp[78116:a0b] Adding request to wl_deviceNoProvisioningRealm challenge handler's waiting list
Please let me know , what does that logs means in worklight.
Checked with one of our developers, who said the message is indicating the request requires antiXSRF authentication, but there is already another request that require antiXSRF authentication being processed therefore the second request is added to waiting list.
This should happen only if the developer fires multiple request simultaneosly, however it shouldn't be an issue and SDK should work. According to what you are reporting above, it sounds like the SDK stops firing success/failure events. If so, we can work with you offline on the recreate steps.

FB App Channel file. ChannelUrl not loading?

I have a Canvas app on Facebook that simply displays a page hosted on our external site. Working just fine.
What I have noticed in Firefox is there is a continuous loading and error being reported in Firebug:
GET http://0-68.channel.facebook.com/pull?channel=p_...1&partition=1&clientid=3744ab1f&cb=b3di&idle=287
200 Aborted
39.86s
This attempt to load always takes around 40s, and is retried instantly after failure. I have also tried loading the above URL by itself, but this just times out with a "Connection Reset" message.
Is this something to do with my channelUrl directive in the SDK setup? I have this setup as follows:
var channel_url = "http://mysite.com/facebook/channel/"; // Aside from the domain, this is the actual final url.
var app_id = "blahblahblah";
// Initialize the facebook object
FB.init({
appId: app_id, // From the globals set up at the top of this page
channelUrl : channel_url,
cookie: true,
xfbml: true,
oauth: true
});
The channel file only has this in it:
<script src="//connect.facebook.net/en_US/all.js"></script>
But I have also tried asynchronous loading the js too.
If I load http://mysite.com/facebook/channel/ in a browser, all is fine.
Any thoughts?
Facebook's JS SDK does long-polling for event updates. If no updates are available the connection will eventually time out, which you will see as Aborted in Firebug.
*copy and pasted from another location
These requests are the HTTP Long-Polling requests. I've only had the Facebook site open for a few minutes and I'm not really monitoring activity but it looks like:
Facebook are using HTTP Long-Polling where open connections are marked as 'pending'
HTTP Long-Poll requests stay open for 40 seconds and after that time if there is no activity that request closes and a new one opens.
If a response is sent (server to client) within the 40 seconds the connection closes (well, that's how HTTP Long-Polling works)