Q: Getting "socket closed by remote peer" when trying to login/sign in to Quickblox server - quickblox

fellow stackoverflowians,
I'm working on a personal project to develop an iOS based chat app that uses Quickblox for its chat functionality.
Just recently we started getting the following error when trying to establish a connection to the Quickblox server and register or sign in a user.
TestApp[3975:76577] -[QBChat loginWithUser:] -> Connecting to Chat, hostName:chat.quickblox.com
TestApp[3975:76577] -[QBChat loginWithUser:] -> Chat server endpoint: chat.quickblox.com, User
Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer}
Sometimes our app is able to log in.. and sometimes it just completely fails all of the time. We cannot figure out if it's the Quickblox server that's having issues or if there's a fix in our code that needs to be added.
Can someone out there please shed some light? We are about to release our app and this is a MAJOR hurdle preventing us from doing so. We cannot get anyone from Quickblox to respond to our ticket. We are an Advanced user (not Pro) and therefore our ticket hasn't been looked at.
Please see the below given code which we use for Quickblox registration and Quickblox sign in. See my inline comments also.
[self CallQBRegister:^{
// I am checking whether the user is already registered or not.
NSLog(#"Successfully registered..");
}
// If already registered then the execution block will come to error block.
// there I am attempting to use Quickblox sign in process.
errorBlock:^{
NSLog(#"Already Registered, Active State is not Changed. Call QB Sign in");
[self callQBSignIn:^{
NSLog(#"QB Login success");
}
errorBlock:^{
NSLog(#"QB Login Failure");
}];
}];
}
After that I am also checking if connection fails I am trying to reconnect with QBChat.
- (void)chatDidFailWithError:(NSInteger)code{
// re login here
[[QBChat instance] loginWithUser:self.currentUser];
}
When ever I am getting this error this code snippet will execute. The code which I am getting here it belongs to an error type, which I have defined in my code. The error what I am getting is "QBChatServiceErrorConnectionRefused".
can anyone help?
Quickblox.. are you listening?

Related

Safari Push notification is not working

I have been trying Safari push notification. I followed the Apple doc.
Downloaded Apple intermediate Certificate AppleWWDRCA.cer. Exported my website provisioning profile as p12. To create the push Package used ruby package push_package
It created a package zip and it contains all the details that we needed - icon.iconset, manifest.json, signature and website.json.
When I request permission it successfully retrieves all data and gives me token.
But the real problem is when I try to send notification from a PHP script or APN tester its not receiving in the safari. The v1/logs getting called instead with some circular Json object.
Have no idea what to do next. can anyone please help ??
And one more thing I found is, in the logs SafariNotificationAgent (unknown version)
The error was in payload that I used.
It should be like:
{
"aps":{
"alert":{
"title":"Hi there",
"body":"How are you",
"action":"viewed"
},
"url-args":[""]
}
}

Trigger.io doesn't expose the user's agreement to notifications in iOS

I am building a trigger.io app (ios+Android) with notifications through parse.com.
Notifications are working, but I am unable to test for whether the user has agreed to notifications before trying to subscribe to a channel with forge.parse.push.subscribe. This is generally only a problem on first run of the app.
forge.parse.installationInfo will return an info.id, even if that user hasn't agreed to notifications, so it can't be used to test for agreement:
forge.parse.push.subscribe throws an error if the user hasn't agreed to notifications:
{ "message":"Subscribing to Parse channel failed: Error Domain=Parse Code=115
\\"The operation couldn’t be completed. (Parse error 115.)
\\" UserInfo=0x165ddbc0 {code=115,
error=There is no device token stored yet.}","type":"UNEXPECTED_FAILURE"}'
I could set a timeout to try subscribing again later in case the user has since accepted notifications, but I'm not happy with having to send multiple REST requests to parse.com to see if the user has agreed to notifications.
forge.parse.registerForNotifications just delays the registration process, but doesn't throw an error if the user doesn't agree to notifications.
Trigger.io displays a console event when the user accepts:
Initializing Parse and subscribing to default channel.
Can this also expose an event to forge to be accessed in the js when the user agrees to notifications?
Or should forge.parse.installationInfo throw an error if the user doesn't have notifications on?

Automatically relogging in to a realm after connection loss in IBM Worklight

My problem is as follows :
I have an application protected by a mobile security test involving a LDAP server. The corresponding realm is called LDAPrealm. I use the form-based authenticator + custom LDAP login module.
When the connection to the worklight server is lost and then re-established, I see that the current user is not authenticated in the LDAP realm anymore.
What I want is be able to re authenticate the user without having him enter credentials again.
However, since the user is still authenticated for other realms included by default in the mobile security test, the worklight server does not challenge the client again for credentials, which is causing j_security_check error when trying to submit credentials.
As a side note those credentials are stored in the encrypted json store for offline authentication and use of the app.
So my question is :
Is it possible to force the server to challenge the client again for this LDAPrealm and use submitLoginForm to re-log in?
More generally, is there a way to clear a user+device from all realms before trying to log in again?
Edit reasons : previous error was caused by a typo
In the case where the user first logs in online then loses connection then get connection again, calling
WL.Client.logout("LDAPRealm",{onSuccess:stealthed_relog});
and calling WL.Client.connect() later in stealthed_relog before sending credentials seems to wield the desired behaviour.
However, when the user logs in offline and then gets connection, when I try to use WL.Client.connect(), it says another instance of WL.Client.connect has already been called.
edit : for the log offline case, the application get challenged automatically shortly after that the connected event fires (cause of heartbeat? I do not really know), so you just have to use
login_clientside.submitLoginForm();
to successfully log in again.
If someone has a better way to implement auto-reconnecting in worklight with ldap server, feel free to post it and I'll unaccept my answer.

GCM - Google cloud messaging: Connection closed when ccs client logins

I created my Project Number, API key, registration ID and implemented a http server sucessfullly, but when implement css(xmpp) server, it doesn't work. I use the tutorial for java in http://developer.android.com/google/gcm/ccs.html
the console displays red alert:
INFO: Loading providers for file [classpath:META-INF/extension.providers]
SASL authentication PLAIN failed: text:
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:342)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:243)
at org.jivesoftware.smack.Connection.login(Connection.java:368)
at server.SmackCcsClient.connect(SmackCcsClient.java:334)
at server.SmackCcsClient.main(SmackCcsClient.java:344)
Apr 16, 2014 3:48:29 PM server.SmackCcsClient$2 connectionClosed
INFO: Connection closed.
line 334 is:
connection.login(username, password);
Does anyone know what is going wrong here? Thanks
I was getting the same Error when I tried to implement XMPP(CCS).So after going through so many site I found that to use up streaming feature of GCM (XMPP) you need to register for this service as a trail partner.
they are saying something like this
After you have created your GCM enabled project in the API Console you must fill out this form and become a trial partner to use upstream messaging and user notifications via CCS. Access is limited to those that fill out the form. You will receive an email from Google informing you that you now have access; Google will also send you the address of an echo server that you can use to bounce messages back to your application.
so visit this site and fill form
Upstream Google Cloud Messaging and User Notifications Sign-up
Update
Now up-streaming using GCM(CCS) is open for all developers !!!

Worklight logoutSuccess auth realm is undefined

I am not able to get Worklight logout working.
The logout button:
<input type="button" value="Logout2" onclick="WL.Client.logout('AuthRealm',{onSuccess: WL.Client.reloadApp})" />
When click to it I get:
onLogoutSuccess: realm: AuthRealm is undefined
But the realm is defined well and logout function of this realm is called after click. I investigated Worklight sources and found out that the problem is in:
onLogoutSuccess(transport=klass { request=klass, transport=XMLHttpRequest, readyState=4, more...})wlclient.js (line 1298)
So the error is thrown from:
if (typeof userInfo[realm] === "undefined") {
WL.Logger.error('onLogoutSuccess: realm: ' + realm + ' is undefined');
return;
}
Where should I set up userInfo? Or why is this error thrown? I didn't find any info in example sources.
I was able to reproduce only when my device had not yet connected to the Worklight server in any way (has not yet logged into the realm, initOnStartup=false, no adapter calls, etc)
It appears that if the client has not yet communicated with the Worklight server, it knows nothing about the realm and so it throws an error when trying to log out of the realm. Try either adding a check to see if the user has logged into the realm or making sure that the user has connected to the Worklight server before they are able to log out.
Even if they haven't yet logged into the realm, the device will know about the realm if it has connected to the server at least once.