Httpconnection in blackberry - blackberry

I am calling a web service from blackberry when I try to open a connection using Http Connection it throws uncaught exception.
"Uncaught Exception: Application is not responding: process terminated"
Everything is working fine if I use EVO or WIFI but in my network few services are blocked and URL I am passing in open connection is also blocked.
I am using this code
url="http://mywebservice/"+ PhoneNo + "/" + RegistrationNo+"/" + PinCode;
String URL = url +getConnectionString()+";ConnectionTimeout=20000";
con = (HttpConnection)Connector.open(URL,Connector.READ_WRITE,true);
Please suggest any solution or how can we check that if requested URL is available or blocked?

An educated guess: You are opening connection via EDT - Event Dispatch Thread (main app thread) this thread can not be used for time consuming operations (connection handling in your example). You need to do these tasks on different threads.

Related

Self-hosted Signal iOS is unable to connect to internet

same issue, other person: https://github.com/signalapp/Signal-iOS/issues/2282
We've checked out the Signal-iOS repository and we're trying to make it connect to another server. We're running an instance of the server at signal.appcraft.nl. We've modified the defines in SignalServiceKit/src/TSConstants.h to match our server and we've changed the domains in App Transport Security Settings in /Signal/Signal-Info.plist
We also cloned the Android app and that one we managed to got working just fine. The iOS app seems not to be able to connect to the internet at all without a clear error. The first HTTP call that is done is GET https://signal.appcraft.nl/v1/accounts/sms/code/<MYNUMBER>?client=ios. When we invoke that URL using curl, we get a response (and SMS) just fine. From the app, we receive a Signal was unable to connect to the internet. Please try from another WiFi network or use mobile data. error. We also changed NSAllowsArbitraryLoads to Yes.
We've added a breakpoint in /Signal-iOS/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m:292
# /Signal-iOS/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m:292
(lldb) expr error
(NSURLError *) $3 = 0x00000001c0244800 domain: #"NSURLErrorDomain" - code: 18446744073709550617
Please advise

cancel file uploading with NSURLConnection

I've got NSURLConnection with timeout = 30s which is uploading an image on server.
If connection is horrible and call delegate method didFailWithError: then i need to cancel current connection.
But if i just call the [myConnection cancel] connection will still alive but will not call delegates methods (apple docs say it - NSURLConnection cancel method). And i want to abort connection but not only remove delegate methods. How i can do what?
upd:
My problem is if connection is fails by timeout - in business logic i must recreate connection with similar request. If i have got horrible connection for 1 min and after that connection will be good - server will get a lot of (about 3 times retry count) photos. But first 2 connections is canceled. –
At the moment i make "dirty hack" like "if it's photo uploading request" - do not retry recreate connection.
I do a ton of network stuff and don't recall a scenario where everything was successfully received but the iOS app timed out. I'm trying to grok the scenario you describe, where you're seeing this happen a lot and I'm not seeing how that would happen. We might need to see some of your code.
Regardless, when you cancel a NSURLConnection, it not only stops the delegate methods from being called, but it stops the upload, too. I just did a test:
I attempting to upload a 20mb file (non-chunked request);
At the 1mb mark (as identified by didSendBodyData), I canceled the connection (by calling [connection cancel]);
I immediately stopped receiving any delegate messages at that point;
Looking at Charles, I'm only seeing 1.3mb of data in the hex log of the request. When I look at the "Network" tab of the Mac OS "Activity Monitor" and looking at by "Sent Bytes", it's at 2.1mb uploaded.
So canceling a connection will stop further data from being sent. Perhaps if there is some transmission in progress that still gets out (that's the asynchronous world we live it), but the it's not true to conclude that canceled connections will routinely send their full HTTP request. There must be something about the nature of the timeout that is unique to your environment.
In terms of your immediate problem, I might suggest that when uploading a file that the iOS app assign some unique identifier to the upload so that the server code can immediately recognize duplicate requests and handle them appropriately. But the question is why you are seeing so many time-outs and notably ones where the request appears to be successfully received in toto, but the response is not. That's very curious.
You cannot forcefully abort an ongoing connection.
In case if connection is not yet started cancel and unscheduleFromRunLoop for the NSURLConnection will work.
Try with following step
[myConnection cancel];
myConnection = nil;
Might be helpful in your case and If this step is not working then also try with myConnection.delegate = nil;

ASIHttpRequest returning 200 when server connection times out or is cut

I am using the ASIHttpRequest library for IOS to attempt to download a zip file from my iPad application and it all works fine. However, I am trying to simulate a request timeout and handle this situation appropriately. I am using a trial version of CharlesProxy to attempt to simulate a timeout and Im also killing my tomcat server. In the situation where I am killing the tomcat server in the middle of the zip download, the ASIHttpRequest is still receiving a 200 response, with the error object begin set to nil even though the download is not complete and is not successful.
I have checked the downloadComplete property on the ASIHttpRequest request object and it is set to YES.
Has anyone else noticed this?

iOS: WebKit discarded an uncaught exception in the webView... <NSInvalidArgumentException> data parameter is nil

My app is coming together now. It's purpose is to search the internet and return JSON data. I realised the importance in catching exceptions such as when there's no internet connection. Now my app will show an alertview explaining that there's no internet connection available - this happens when the NSData returned is nil (because of the lack of internet) so how would I go about catching the exception itself?
You're not looking for an exception, you're just looking for the reachability of the network. This post has great info:
How to check for an active Internet connection on iOS or OSX?

TimedOut Exception when register for Black berry Bis push service

Right now i am working on Blackberry "BIS push service",
when i register with bis from my device it shows timed out exception.Can any one please tell me what is the problem.I am connecting using WIFI
Here i am the url.
REGISTER_URL = BBP_SERVER
+ "/mss/PD_subReg?serviceid=" + APP_ID + "&osversion="
+ getDeviceSoftwareVersion() + "&model="
+ DeviceInfo.getDeviceName()
+ ";ConnectionType=mds-public;deviceside=false;interface=wifi";
Due to minimum info provided I can only presume that you made beginner mistake and just did direct http connection without using threads, therefore your http request easily times out. If that is case have look on this entry Networking, User Experience, and Threads. If you did use threads then you need to post code otherwise it will be impossible to help you with it

Resources