PushSharp "Notification send timed out" issue - google-cloud-messaging

I am trying to use PushSharp to send notification to my mobile devices using Google Gcm.
I downloaded the sample application from github depending upon that I have written my sample code. below is my sample code.
var googleKey = CustomConfigurationManager.GetValueFromSection("appSettings", "GoogleServerAccessKey");
AndroidPushBroker.RegisterGcmService(new PushSharp.Android.GcmPushChannelSettings(googleKey));
GcmNotification androidNotifcation = new GcmNotification().WithDryRun()
.WithJson("{\"alert\":\"Hello World!\",\"badge\":7,\"sound\":\"sound.caf\"}");
AndroidPushBroker.QueueNotification(androidNotifcation);
The issue is though I have used WithDryRun() and upon hooking up request it shows json data with "dry_run": true, but still I receive Notification failed error with reason : "Notification send timed out".
Anybody can tell me what am I missing ?

try to run it without WithDryRun(), and see do you get anything in events like NotificationSent, ChannelException, NotificationFailed or ServiceException.

Related

How to await a WebSocket response in gatling without sending a message

I'm working with WebSockets in Gatling and have a slight issue in that I get multiple responses with the same message and different values, but the original message is sent only once. The subsequent web socket responses are triggered by a graphql post.
Obviously .exec(ws("Web Socket Request").await(5) doesn't work so Im wondering how I would await and check the subsequent message?
You can see the requests in dev console here. Message with "id": "11" is sent and message with "id": "11" is received, then another one ("id": "11") is received after the graphql call.
So my code currently looks like this:
.exec(graphQlRequests.onlineStatus(false))
.exec(graphQlRequests.chatRooms())
.exec(
ws("Video Watch").sendText(subscriptionQueries.videoWatch()).await(5)
.on(ws.checkTextMessage("Video Watch").check(jsonPath("\$..choices[0].id")
.saveAs("choice")))
)
.exec(ws("New Messages").sendText(subscriptionQueries.newMessages()))
.pause(1)
.exec(graphQlRequests.startVideo())
.exec(graphQlRequests.chatRoom())
.exec(graphQlRequests.onlineStatus(false))
.exec(graphQlRequests.chatRoom())
.exec(graphQlRequests.onlineStatus(true))
.pause(9)
.exec(graphQlRequests.onlineStatus(true))
.pause(3)
.exec(graphQlRequests.videoChoice())
// Capture the second WebSocket message here.....
.exec(graphQlRequests.onlineStatus(true))
.pause(15)
.exec(graphQlRequests.onlineStatus(false))
What is the best way to capture the second request? Do I need to open up a separate SSE connection?
That's a similar issue as https://github.com/gatling/gatling/issues/3809.
In short, the expected WebSocket inbound message might have already been received between your HTTP request and your WebSocket await, so the latter misses it.
You're welcome to help with specifying a proper solution on our bug tracker (but no "upvote", "me too" or "+1" please, it doesn't help in any way and doesn't make things happen faster).

How can a Slack app communicate to the user why a slash command failed, and let the user edit the command?

When an app fails to handle a Slack slash command, the text is brought back to allow the user to edit it and immediately send it again. I have a slash-command that searches, but might fail to find any results. In that case, I would like the user to immediately be able to modify their search. The Slack docs explain that I should always return a 200 HTTP status, but then Slack also erases the command and the user can't immediately try again. When I tried to respond with a 404 status, the users get an alarming message like failed with the error "http_client_error". Is there a way to fail but also provide a custom message to the user why?
Yes, but you must not use HTTP status codes to community a failed search.
Just always return HTTP OK 200 and then add a response message telling the user what went wrong. You can do that by directly replying to the request from Slack within 3 seconds, or alternatively by sending a message to the response_url.
This is also clearly expressed in the offical documentation for slash commands:
Sending Error Responses
There are going to be times when you need to let the user know that something went wrong - perhaps the user supplied an incorrect text parameter alongside the command, or maybe there was a failure in an API being used to generate the command response.
It would be tempting in this case to return an HTTP 500 response to
the initial command, but this isn't the right approach. The status
code returned as a response to the command should only be used to
indicate whether or not the request URL successfully received the data
payload - while an error might have occurred in processing and
responding to that payload, the communication itself was still
successful. (Source)
As far as I know it is not possible to signal Slack that the user should be able to edit his last command though.

push notification IBM MobileFirst 7

I have written IBM Adapter for push notification.I able to fetch device Id from device using 'WL.Device.getID'.I want to send push notification on the device but there is no way to subscribe.and did not find a way to subscribe push notification Event source in java adapter as mentioned in demo javaScript adapter. When I called sendMessage() method through pushApi , I got exception that PushApplication was not found.
Also to handle the challange , we use WorklightProtocolAuthenticator .
Please help how i can send push notification using java based push adapter.
Below is my adapter :-
WLServerAPI api = WLServerAPIProvider.getWLServerAPI();
PushAPI pushApi = api.getPushAPI();
INotification noti = pushApi.buildNotification();
noti.getTarget().setDeviceIds("a5be4b35-b278-3014-b933-ce99a8l87819");
noti.getMessage().setAlert("text to be send on device");
pushApi.sendMessage(noti, "ApplicationId");
And how can i get this ApplicationId.
Please help how i can send push notification using java based push adapter.
You do not find what you are looking for because AFAIK it does not exist. The APIs are available only in JavaScript.

How do you get IBM MobileFirst Platform ChallengeHandler to handle very large responses correctly?

When working with a large-sized data response from an HTTP Adapter, the size of the response appears to cause our challenge handler to fire a handleChallenge() method.
My question is, why would the size of the response cause the mobilefirst security challenge handler to fire, when the session is still valid?
More Details:
Our application uses an ISAM security appliance with Header based authentication. When an HTTP adapter call we make comes back with a content-length greater than 20,377, the adapter call triggers the handleChallenge() method of our challenge handler. When inspecting the response, we have seen that the responseJSON is actually populated with our required data, so really the handleChallenge should never have fired.
When we ping the adapter directly through the browser with the same parameters, it works fine. We've been able to isolate that this problem is occurring in the worklight.js / mobilefirst realm.
Does anyone have any idea if, or why, the Challenge Handler in worklight.js would not function as expected with a very large response size?
The bottom line is that it should. There is no reason for it not to.
If you have not been able to resolve this otherwise, my suggestion is to open an IBM PMR (support ticket) to have the development team investigate the issue.
We ended up ( sort of ) diagnosing it. At a certain payload size, the "/*secure {" fell off the response ( of which we're still not certain why. Our loginChallengeHandler function was based off of some example we found in some IBM documentation, and would improperly mark the response as a login form if the /*secure wasn't present. Once we tightened up the challenge handler, it worked.

Remote server returned an unexpected response :(417) Expectation Failed: Using MS Translator API in Windows Store App

I am trying sample code of Microsoft Translator in Windows Store App from this link
The sample code is given here
When I run the app, I get an exception "The remote server returned an unexpected response :(417) Expectation Failed"
This exception occurs on the following line:
germanTranslationTextBlock.Text = await webService.TranslateAsync("Bearer " + accessToken.access_token, sourceTextBox.Text, "en", "de", "text/plain", "");
P.S. I am behind a proxy.
Some googling shows that System.Net.ServicePointManager.Expect100Continue = false; is the solution but I do not know how to do that for Windows Store App.
Could not solve this error, but got a better and infact best source code [which works successfully] for doing text to speech and translate too here.
Could have saved a lifetime if I would have found it earlier, but it's really hard to find any good resources for windows app development.