WL.Clinet.connect - throwing error - CONNECTION_IN_PROGRESS - ibm-mobilefirst

MFP Product version: 8.0.0.00-20180220-083852
MFP Client Vesion: 8.0.2018080605
I have an app which is using requireJS, backbone & jquery.
I am loading the main js like this:
<script data-main="js/main" src="js/lib/require/require.js"></script>
I am making sure the call to main.js is made inside wlCommoninit. The app is loaded with all dependencies.
function wlCommoninit(){
main(); // main.js has a single method named - main
}
I have a call to "WL.Client.connect" # the end of main function- which just executes & does nothing.
A subsequent call to "WL.Client.connect" returns the following error message:
Failed to connect to Worklight Server:
{"responseHeaders":{},
"responseText":"undefined",
"errorCode":"CONNECTION_IN_PROGRESS"}
What could be the reason for the above error? Though we make a call to WL.Client.connect inside wlcommoninit. Hopefully all the WL API would have loaded by the time 'wlCommoninit' is invoked.
Tired with different MFP clinet sdk versions other that mentioned above. I don't see any change.

The reason for the response
{"responseHeaders":{},"responseText":"undefined","errorCode":"CONNECTION_IN_PROGRESS"}
is that before the first WL.Client.connect() succeeds or fails, you have fired another connect() call.
Wait until the first succeeds, fails or times out from inactivity.

Related

Ionic capcitor + vue Network error " Request aborted at e.exports (chunk-vendors.85bc3696.js:1) at XMLHttpRequest.m.onabort" on android emulator

I'm using Ionic/Vue and wheen I run the application in my browser it works well but when I compile and run on an android emulator I get the error below. Please help
Error: Request aborted at e.exports (chunk-vendors.85bc3696.js:1) at XMLHttpRequest.m.onabort (chunk-vendors.85bc3696.js:26)
That error indicates that some of your vue components gets destroyed before ajax request gets completed. Check over all your code - everywhere you invoke remote service make sure that you 'await' result before allow anything to switch to another route, which leads to components disposal. Sometimes you need to do 'unsubscribe' from http request in component disposal
Actually, that probably is not an error - that is normal that request gets aborted if result is not needed anymore

Is there a way to bring up a Yii console like 'rails console'?

Is there a way to interact with Yii on the command line with a console like rails console? I'd like to test DB and ActiveRecord calls.
You can install yii-shell. It's made by the Yii team. It works like rails console
EDIT:
Sorry, I worked from the documentation of yii-shell which is - at the time of this writing - but a promise.
This is how you can get a proper REPL working in Yii 2.
First, we would need to get Psysh. You can install it globally to play with it, but I recommend adding the following line to your composer.json
require-dev: {
// ... some other packages ...
"psy/psysh": "0.7.2"
}
Run composer update to get this package installed.
Now we need to add this to a controller. The way to call up the break point from a controller is eval(\Psy\sh());.
Note that this would invoke the console for debugging. So if your app is served with Apache, Nginx, or any other server which is not tied to an interactive console, this is pointless
For this to work, I have served the application using PHP's inbuilt server and Yii's wrapper for it.
In Yii Basic App template...
cd /path/to/application
./yii serve localhost:12345
In any controller, ...say controllers/SiteController.php
public function actionIndex()
{
eval(\Psy\sh()); // <-- debugger point
return $this->render('index');
}
When you access this action via tha URL, it would hang on your browser. If you check back in the console, you would see an interactive shell which should work like rails c. Checkout the Psysh Documentation for more details. To exit this interactive console, type exit; this should return control back to PHP's inbuilt server. Do not exit the interactive console with Ctrl-C as this would close the PHP's inbuilt server also.
In Yii Advanced App template...
Serving the application does not work at the moment since it defaults to serving the contents of console/web which doesn't exist. I have raised an issue with Yii; you can follow along there if it interests you.
However, if you have console controllers, you can do the same thing we did for the basic app. When you run the console command, you should be presented with the same interactive debug console.
1) Install https://github.com/yiisoft/yii2-shell
composer require yiisoft/yii2-shell
2) ./yii shell

How to override default action when Apps cannot connect to Server?

The apps shows below screen when the connection to server is unsuccessful, but our customer doesn't wan the user to be able to view the "Details" of the error which I had no idea how to remove it. Can we override the default behaviour and show a custom screen instead?
Thanks in advance.
You can use WL.Client.Connect API to connect to Worklight server, and use it's onSuccess and onFailure callback functions to show the users whatever you want. More information can be found here: http://pic.dhe.ibm.com/infocenter/wrklight/v6r1m0/topic/com.ibm.worklight.dev.doc/devref/t_ConnectingToWorklightServer.html?resultof=%22%63%6f%6e%6e%65%63%74%22%20
If you had specified the
ConnectOnStartUp=true
in initOption js file then on starting up itself it will try to connect with the server , In that case use there will a for connection failure,it will be commented first in init Option.You have to uncomment it in initOption js file and give something to do when the connection has failed in that function . So the error will be customized

Worklight - connection on startup fails

using Worklight server v6.1 i'm trying to develop a simple app that connects to the production server at startup. To get this i do:
in initOptions.js file i set connectOnStartup to true
in wlCommonInit method of <my-app>.js file i call :
WL.Client.connect({
onSuccess: connected,
onFailure: failure
});
where connected and failure are two callback to two simple functions that load some data in a listview. When i trie it on a production or development environment i get a spot over my app's layout stating it's loading as you can see in the pic below(even if the application loaded data correctly):
i notice that after installing and running it on an iOS or Android device i don't have this strange behaviour, but on Windows8 devices i do have.
i set to false connectOnStartup and left only the call to WL.Client.connect.
Now the app doesn't get blocked anymore(i suppose becouse WL.Client.connect runs asynchronously while WL.Client.init does not but it's only my opinion).
i can't connect to the server yet, this is strange becouse(you can see in the pic) there is a listview filled with data returned by a sql adapter,
so it looks like the app can connect to the server for calling adapters but not for updates
You have already set connectOnStartup:true in initOption.js, this means that the app will try to connect to the Worklight Server on startup - basically it calls to connect, so why do you call WL.Client.connect in wlCommonInit() as well?
As for the onSuccess and onFailure, I think that in this what you may want is the following:
See the options for WL.Client.init.
There is an initOption that you can uncomment in initOptions.js:
onConnectionFailure
A failure-handling function invoked when connection to the Worklight
Server, performed on initialization by default, or if the
connectOnStartup flag is true, fails.
The "success" by default is wlCommonInit(), but you want something else then in initOptions.js you can also add onSuccess: something.
BTW, where did you see what you've done as a "best practice" by Worklight?

How to replace Jetty's default error page when the server is muted

I'm trying to handle a use case where my server is muted and a user try to access it.
Today when the server is muted the user get the jetty's default error page for 503 (HTTP ERROR: 503).
I would like to replace this error page with a custom error page.
I do have custom pages on my web.xml, but it is not loaded (since the server is muted).
I tried writing my own error handler that extends ErrorPageErrorHandler, and I registered it on jetty-web.xml
O debug I see that my class is loaded, but it does not activate when the error happens.
I'm muting the server by stopping my DB service. It seems that this causes the ContextLoader to fail. Here is a partial stack trace, any insights would help:
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:643)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:233)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1213)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
at org.eclipse.jetty.server.Server.doStart(Server.java:261)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at com.hp.qc.JettyRunner.startJetty(JettyRunner.java:73)
at com.hp.qc.JettyRunner.main(JettyRunner.java:31)