is there any way to execute a mobilefirst adapter without direct client call? In other words, I need to do some operations in database data in timed mode (e.g. every tot secs).
Is there any way to do something like this?
There is no other "official" mechanism to call an adapter function other than polling, but that is specific to push notifications and not for general adapter usage: https://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.dev.doc/devref/t_configuring_a_polling_event_source.html
Related
I have a client that is using EAP(Event-based Asynchronous Programming) to call WCF service asynchronously.
But when I try to close the client proxy after calling the service I see that client hangs up and it works in a synchronous manner.
When I don't close the client proxy after calling the service the call works fine in asynchronous manner.
Do I need to close the proxy in some different way when using EAP ?
I need to process large number of concurrent requests asynchronously.
Strictly speaking, we do not need to close the client connection because the server automatically closes the connection.
This depends on the following parameters.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/configuring-timeout-values-on-a-binding
Besides, I suggest you enable the concurrency on the server side.
https://learn.microsoft.com/en-us/dotnet/api/system.servicemodel.servicebehaviorattribute.concurrencymode?view=netframework-4.8
Feel free to let me know If there is anything I can help with.
I have a SQL Worklight Adapter with procedures that should not be exposed to anything except my http Worklight Adapter. I cannot have the procedures as private functions in the http adapter since you cannot mix SQL calls and HTTP calls in the same adapter.
I have considered defining a security test to only let invocations coming from the server use it, is there a secure way to do this? Is there any other approach I should use?
I use Worklight 6.2.0 CLI version.
You could use a "poor-man's" security approach, code all your DB adapters to take an extra parameter, require that parameter to take some value that only the server can supply.
Using a security-test can surely be made to work, I'm just not sure how much work it will be. So far as I know you don't have the ability on the server to install a ChallengeHandler, and hence use the simple authentication patterns in the tutorials. So I think you'd be into writing your own Realm.
My question would be whether there is real value in doing this. Suppose instead you just protected all your adapter procedures with the same security test (and that's much easier because the standard ChallengeHandler patterns work because the procedure client is in the WL.CLient space). Now only clients authorised to use the HTTP adapters can use the SQL adapters. What extra privilege have they gained by going direct to the SQL adapter? If you are doing some additional security checks in the HTTP adapter perhaps this needs refactoring into the security layer or some common functions.
I am sure that this is answered dozens of times, but I am at a loss as to what keywords to search for and thus I hope that someone can at least tell me where I should be looking given an explanation of my scenario.
I need two services (one can be just a client if that is easier) to talk to each other, but the client will be on a private network whereas the server will be on the internet. I want to be able to push jobs to the client, but the server obviously does not have an IP to hit the client. I'd rather not poll from the client every X seconds. I have read various topics all circling this issue and so I am going to throw out a few terms that I think are relevant, but I am not sure which to use or exactly how.
Comet, SignalR, WebSockets, XSockets, Publisher/Subscriber Pattern...
I have looked at each of these and I am not sure which is the right way to go. The client can certainly "subscribe" to the server on startup, so that should not be an issue. But the client should be either a console app, windows service, or WCF service. It seems Comet and SignalR are more for ASP.NET apps, where the client is JS in a browser. I just need "server(client)" to server connection where the client is behind firewalls.
Which of these terms (or none of them) is a good way to handle server -> client push notifications?
Pub/Sub architecture pattern with something like Azure Service Bus should help you create the solution you desire. This does require that service and the client are aware of the bus. For the plumbing of the client and the services use the WCF which has built in bindings to facilitate the use of this pattern.
Azure: How to Use Service Bus Topics/Subscriptions.
Azure SB has a counter part that works on-premises as well. There are other popular message bus tech (NServiceBus, MasTransit, etc.)
You can have a look at node.js together with socket.io.
This will give everything you need.
socket.io uses web sockets, and if the browser does not support web sockets, it gracefully falls back to other communication mechanism like xhr, flash, polling, aso.
In our project we are trying to figure our what the best process to connect to the server will be - especially when taking care of offline/online scenarios etc.
Right now, for us, it seems that all three options to connect to the WL server are similar. Whatever option we use, we can call our Adapter Procedures perfectly and we receive Notification Messages that are set in the console.
We are not sure about Direct Update - this is not working properly yet.
Are there any important differences between these three ways of connecting to the WL server, or is basically the same connection procedure being executed in all three cases?
How about WL.Client.init() before connecting - could we call that again (in addition to the standard window load EventListener) in our code before we connect using a WL.Client.connect manually - or is init() supposed to be called only once?
Tied to that is also offline and re-connecting.
As far as I have read in the tutorials, the WL Client framework is managing the connection state. Does that mean that when the WL client is connected to the server through any of these three ways and loses it's WLAN/3G/4G connection (or it's access to the WL server due to internet connection blocker or so) it re-connects automatically (regularly tries to re-connect until successful) when a connection to the WL server is available again?
EDIT
I was thinking about Events or Threads that provide more low-level information (not WORKLIGHT_IS_CONNECTED) - basically events that would be triggered when the device loses/gets WIFI/3G/4G connection and/or internet connection. Or is there only polling using WL.Device.getNetworkInfo() available?
Would the use of Cordova Event like:
document.addEventListener("offline", yourCallbackFunction, false);
provide a functionality close to that?
Though those three ways do have some similarities the differences between them are very important.
WL.Client.init() initializes client side WL framework.
WL.Client.connect() triggers connection request to WL server.
initOptions.connectOnStartup defines whether WL.Client.connect() will be invoked automatically during WL.Client.init().
In general - most of the functionality (e.g. adapters, remote disable) will function even if you call WL.Client.invokeProcedure() without calling WL.Client.connect(). But there are several things that will not function:
You will not be able to fully utilize push notifications without calling WL.Client.connect()
Direct update is triggered during WL.Client.connect()
WL.Client.connect() will get security related info from server, e.g. names of realms, whether user authenticated in those realms etc. Therefore all APIs like WL.Client.getUserInfo, .isAuthenticated(), .getUserName() etc will not function.
It is strongly recommended to start your session with WL.Client.connect() (or initOptions.connectOnStartup=true).
The project im working on, they would like active server connection detection before each call.
Im trying to find out if its better to use:
WL.Device.getNetworkInfo:isNetworkConnected
or
WL.Client.connect
I know that getNetworkInfo only checks if the phone has contectivity to the net, while wl.client.connect will actually connect to the server. Im just afraid that wl.client.connect will be an expensive call to make before every invokeProcedure call. Is there a better way to check for connectivity before the invokeProcedure call?
getNetworkInfo API can be used to verify whether device currently has an internet connectivity.
As for WL server connectivity there is only one way to verify that server is accessible and this is by issuing a request to WL server and verifying whether it succeeded. However this is not right way to go. Every WL server invocation API, e.g. WL.Client.connect(), WL.Client.login(), WL.Client.invokeProcedure(), has onSuccess and onFailure callbacks. Use them to verify whether server connectivity was successful or not.
Technically, even if you do additional request like WL.Client.connect() before making a real request it will not give you 100% assurance that the real request will succeed.
In addition you may want to utilize WORKLIGHT_IS_CONNECTED and WORKLIGHT_IS_DISCONNECTED events which are fired each time last WL server invocation status toggles success<->failure. Check out the offline training module at Worklight Getting Started page.