When i receive a push notification when the application is closed and i click on it, only the application open and nothing happen,
it only show me popup when application is open or reduced
What to do ?
thanks
This appears to be a defect in the product - you need to open an IBM PMR (support ticket) in order for the development team to investigate and possibly provide a fix.
I had the same issue with Worklight 6.2, using Unicast Push Notifications.
I think the problem is that the Push Notification Listener gets initialized after the payload is actually processed.
The workaround I found is to force a (even fake) notification subscription after the application connects to the Worklight Server (which means on the success of WL.Client.connect or on the response of the first adapter call).
WL.Client.Push.subscribe("myPush", {
onSuccess : doSubscribeSuccess,
onFailure : doSubscribeFailure
});
Note that this will not work if you are using EventSource based notifications, but only Broadcast, Unicast and Tag. I think you can make it work also with EventSource, but it would be a bit more complicated as you will have to also handle the registration to the event.
Related
I am using SignalR for the 1st time in my asp.net c# web app.
I am using HTML 5 and JavaScript for my client web page.
In essence whenever my server has an image to 'push' to my clients it does so. Sometimes this can be quite frequent.
Now, I imagine during a 'busy' period' my client(s) could be 'over-whelmed' by the data being pushed by my server?
How does my server know that the message has been recieved by my client (or not) and then proceed to send the next one?
SignalR doesn't provide a built-in way to wait for a client to receive a message. This would be very difficult to do in the general case where someone might be using Clients.All, and clients might be connecting/reconnecting/disconnecting at the time the message is sent.
However, it is possible to manually acknowledge that you have received a message on the client (perhaps by calling some hub method on the server), and then continue to send the next message once the acknowledgement (ACK) for the previous one has been received.
I have following scenario:
User request for certain resource on server, This request is long running task and very like 2~3 seconds to 10 seconds. We issue a JobTicket to user, As our user want to wait.
On receiving request we store that request in persistence storage and issue a token to user as JobTicket (GUID).
User make connection with Hub to get information about that GUID.
In Background:
We have WAS Hosted as well as Windows Service to perform some operation on that request.
On complete, WAS Hosted/Windows Service call our Web Application that job has been completed.
From there based on job Ticket we identify which user and on its connection we let user know its job has been completed.
Now we have farm of servers, we are using Windows Server On Prem ServiceBus 1.1 which is working fine, But challenge we have is that we are not able to intercept ServiceBus based backplane message broadcast and message is going to all the client. As we have farm, user intermediately may have drop connection and connected to other server based on load balancer so we need to have scale out using Service Bus as its kind of seamless to integrate and we are also using for our internal purpose in our application so we don't want to user any other mix in complex solution.
I have tried using IHubPipelineModule but still Scale out message broadcast not passing thru that, I tried to hookup SignalR code directly and debug thru it but its taking long. I don't want to mess-up something arbitrary in actual code. As I can see that in OnReceive I can see message are coming, but not able to follow further. I just need small mechanism that I can intercept broadcast message and make sure that it goes to client it intended and not all the client by wasting resources, and security concern as well.
Please help me on this issue, it's kind of stuck from last 4 days and not able to come to any solution and same time I want to go with establish pattern and don't want to fork any special build for this kind of small issues which I am sure one of you expert knows how I can do that seamlessly.
Thanks,
Shrenik
After lots of struggling and not finding straight forward way, I have found the way as below for someone else in future it might help.
Scenario:
1. Web Farm: Host External User facing Web Pages
2. Backend Process: Which is mix of WebApi, SharePoint, Windows Service etc.
User from Web Page submit some request and get a unique id as return back. Internally on receiving request, we queue that request to Service Bus using TopicClient for processing.
There are pool of Windows Service watching on Message on Service Bus using SubscriptionClient and process that message. On completion of process which can run from 5 seconds to 30 seconds and some cases even more. We need to inform client that its job done if its waiting on web page or waiting for completion notification.
In this story, We are using SignalR to push job completion notification to client.
Now my earlier problem is How I let know from windows service to web application that job is done so send notification to client who submitted request.
One way is we hosted another hub internally in web application, Windows service act as client and call web application hosted hub, and in that hub method it will call external facing hub method to propagate message to specific client who submitted request, for which we are using Single user Group.
And as we have register service bus as backplane it will propagate to other servers and then appropriate client will get notification. So this is ideal solution and should work in most cases.
In above approach we have one limitation that, how Windows Service connect to Web Client, as we donot have windows auth, but we have openid based auth with ADFS. Now in such case Web Application required special code in which provide separate userid or password for windows service to communicate or have windows authentication also allowed for that hub for service account of windows service.
I was trying and trying how to remove all this hopes between interserver communication and again management of extra security.
So I did below with simplicity, though it tooks me whole night to find our internal of SignalR. But it works:
Approach is to send message directly to ServiceBus Backplane, and as all Web Server already hooked-up with ServiceBus backplane then they will get message.
Unfortunately SignalR doesn't provide such mechanism to send message directly to Backplane. I think its on pub/sub model so they don't want somebody to hack in their system :). or its violation of their pattern, but its make sense, in my case because of different roles and security, I have simplify code as below:
Create a ServiceBusMessageBus instance in my code, Same way as Below: Though I have created separate instance and store till lifetime of Windows Service, so I don't create instance every time:
ServiceBusMessageBus serviceBusBackplane = new ServiceBusMessageBus(new DefaultDependencyResolver(), new ServiceBusScaleoutConfiguration(connectionString, appName));
Create a ClientHubInvocation Object: This is a message which actually get created in SignalR infrastructure when Backplane based message broadcast:
ClientHubInvocation hubData = new ClientHubInvocation
{
Args = new object[] { msg },
Hub = "JobStatusHub",
Method = "onJobStatus",
State = null,
};
Create a Message object which accept by ServiceBusMessageBus.Publish, Yes, so this is a method which actually get called on base class ScaleoutMessageBus.Publish. This class is actually responsible for sending message to topic and other subscribers on other server nodes. Why not use that directly. Now to create Message Object, You need following code:
Message backplaneMessage = new Message(
sourceId,
"hg-JobStatusHub." + name,
new ArraySegment(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(hubData))));
In above second parameter is something interesting,
In case if you want to publish to all the client then syntax is "h-", in my case specific group user, so syntax is "hg-.. You can check the code here: https://github.com/SignalR/SignalR/blob/bc9412bcab0f5ef097c7dc919e3ea1b37fc8718c/src/Microsoft.AspNet.SignalR.Core/Infrastructure/PrefixHelper.cs
Publish your message to backplane directly as below:
await serviceBusBackplane.Publish(backplaneMessage);
I wish this PrefixHelper class have been public.
Remember: This is not recommended way and doent insulate from future upgrade for SignalR, as its internal they may change so any upgrade might come with small hazale to change this code. But in summary this works. Hope SignalR Team provide some mechanisam out of box to send message directly to backplane instead.
Thanks
I want to know what is exactly the behaviour of wlCommonInit() function.
I have moved my initialization code into this function, but then it seems to be not called in the case of connection to the server failure.
is wlCommonInit() called when the Worklight server is not reachable ?
If I want to use direct update, I want to call WL.Client.updateUserInfo() on my initialization, and I want the app to be working also in offline mode, does this mean I must implement onConnectionFailure in wlInitOptions ?
If I implement onConnectionFailure in wlInitOptions, can I display the default popup that inform about the connection failure, and provide details ?
It really depends on the logic you wrote in your "initialization code" IMO. The question is somewhat cryptic...
The wlCommonInit function is called once the Worklight framework has completed initialization. If you set connectOnStartup to true, only if connection to the server is successful, it will then be called.
Direct Update is not related to any specific API you implement in your application. If you change any web resource in your project (HTML, CSS, JavaScript, images, ...), this will trigger a Direct Update in the application.
A Direct Update is checked in 2 scenarios:
on application launch, and
on return to the foreground (if the app was in the background)
The Direct Update check is performed only if and when the application connects to the Worklight Server. If you did not previously set your application by either using connectOnStartup:true or used WL.Client.connect or invoked an adapter procedure (all three send a request to the server), the Direct Update check will not be done.
If you choose to override the default dialog provided by Worklight by using onConnectionFailure, the Details button (which I assume if what you wanted) - is not available. By overriding, you select to fully customize it.
I've read the following post about how to push data from BlazeDS without recieve message from Flex client?. I did not posted on that thread because is old.
I've implemented such mechanism and it seems to work well. The only thing that I did not managed to do is to stop the thread, if the client is closed. My hunch is that the client is closed, but the consumer is not unsubscribed, unless the method unsubscribe() is not called and I would say, that this is a normal behavior. The problem is that if I want to call the unsubscribe method when the client (in my case a browser) is closed, I did not find such handlers (e.g onExiting, dispose...) in flex web, only for air applications. I'm developing my application using Flex 3.6 and BlazeDS 3.2.0. Thanks.
There is no default handle for that in flex.
However, what you could try is the following:
Hook into the javaScript onBeforeUnload method => JavaScript + onbeforeunload
In this javascript method, call a Flex function via the ExternalInterface API
In your Flex app unsubscribe
Cheers
How to detect which clients was disconnected? I'm using Hub and saw the chat example where the IDisconnect interface was implemented. De Disconnect() function is called when a page is refreshed or closed, for example. It's working ok, but how to detect which one was disconnected ?
There's a Client id property on the Hub (Context.ClientId) that you can use to figure out which client disconnected.