BlackBerry OS 6: IOException:"peer refused the connection" on specified url - blackberry

Calling
Connector.open("http://MySpecifiedURL.com;deviceside=true;apn=rim.net.gprs");
Throws IOException: "peer refused the connection".
This happens only with few specifies URLs, that used for web services and only on BlackBerry OS 6, on other OS versions (5.0 and 4.*) and with other URLs everything works correctly. Can somebody help me with understanding why this happens?

A "peer refused the connection" error occurs when the server doesn't like something about the connection, i.e. you didn't supply the right userid/password to the APN, or there's nothing listening at that port. My first try would be to drop the apn= part of the connection string.
But if I were you, I would switch to using Versatile Monkey's networking helper class which will find the best TCP connection path for the device, regardless of OS version. It will let you handle the cases where devices are paired with a BES or not, if Wi-Fi is available, etc. It's really easy to use and solves a lot of connectivity problems that BB developers face given the mix of devices out there with BES, BIS, Wi-Fi, etc.

The definitive answer to this subject I found it in "Apress Begining Blackberry Development Nov.2009".
From page 186 to 190 more or less... they throw out a perfectly written code for this... you invoke this Method they define and it will return the extra parameters needed to make a proper request depending on the network availability.
I cannot paste the code here since that would be illegal.
Cheers!.

Related

iOS Bonjour local service discovery

I have an issue in my app where if a client is running my app but does not have wifi enabled, the app does not find my service and returns an "Unknown error" CFNetServiceError code 72000. The client enables wifi, connects, and my app is clueless.
The obvious fix is to add a notification for when a local wifi network is connected and reinitiate the NSNetServiceBrowser's search.
I don't know how to do that in C, so I was hoping to use Reachability. To my dismay, the solution I seek has recently been removed.
This is from the Reachability ReadMe file.
Removal of reachabilityForLocalWiFi
Older versions of this sample included the method reachabilityForLocalWiFi. As originally designed, this method allowed
apps using Bonjour to check the status of "local only" Wi-Fi (Wi-Fi
without a connection to the larger internet) to determine whether or
not they should advertise or browse. However, the additional
peer-to-peer APIs that have since been added to iOS and OS X have
rendered it largely obsolete. Because of the narrow use case for this
API and the large potential for misuse, reachabilityForLocalWiFi has
been removed from Reachability.
Ok, fine. But what the hell are these additional APIs? I need a method. :(

A single case of Safari on iOS9 not connecting to websocket

I have an issue with a single (at least for now) iPhone not being able to connect to websockets. Unfortunately I don't have access to the device and I can't run more tests on it at the moment, so no proper network dumps or anything else deeper level debugging available. Can't test on other network connections either at the moment.
Everything works perfectly with Chrome 45, Firefox 40, Chrome 45 on Android (many devices), Safari on iOS9 (device A), Safari on iOS8 (device B) etc. No errors, no cutoffs, nothing. Just works.
My websocket server runs on IIS 8.5 / ASP.NET, created as an API controller with the typical way (PullHandler is an async Task whileing until connection closes)
if (HttpContext.Current.IsWebSocketRequest)
{
HttpContext.Current.AcceptWebSocketRequest(PullHandler);
return Request.CreateResponse(HttpStatusCode.SwitchingProtocols);
}
else
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Bad request");
This should not cause any issues, especially this one. The client side JavaScript is also the simple
new WebSocket("ws://" + window.location.host + "/api/Some/Endpoint);
I am using plain HTTP, no SSL/TLS.
When trying on iPhone device X with iOS9 (13A344, not entirely sure of which model) it just can't get the connection. I am also using SignalR which automatically goes into longPolling transport on this device. With others it's nicely on webSockets transport.
Quick testing on UK Orange 3G connection showed on my HTTP logs that for some reason the request for my endpoint has gone to the else branch, like something had stripped the upgrade headers away.
GET /api/Some/Endpoint 80 - Mozilla/5.0+(iPhone;+CPU+iPhone+OS+9_0+like+Mac+OS+X)+AppleWebKit/601.1.46+(KHTML,+like+Gecko)+Version/9.0+Mobile/13A344+Safari/601.1 - 400
Status 400 is clearly showing the bad request that my code is sending if the request is not a proper websocket request. I don't know if there could be some transparent proxy, that could explain this. The 400 response was received without any delays.
But this was a problem also through wifi on the same device. Again, a laptop with OS X and Safari had no issues on the same wifi to connect to SignalR and my websocket server. Only the iPhone had issues. On wifi I didn't get any attempts to connect on the logs and SignalR also immediately went into longPolling transport. The wifi apparently used Virgin Media's network based on IP address.
On wifi there is first an open event. Then after some time there is a close event with status 1006, which is abnormal termination without a close packet. My code tries to connect again and the same happens. Strangely there is no log entry at the web server, but it might just be Safari's way to post the open event even though an actual connection was not established and after a timeout it sends the close event.
The device should not have any proxies set up and other browsing works without issues. Unfortunately I couldn't get any information about any other site that would use websockets working or not on that device.
Has anyone run into this kind of situation? I do understand that the 3G might just be a misbehaving proxy, but the wifi issue cannot be explained with that.
Just want to expand the universe for this issue.
I Have an app that runs great in simulator. App has both http Jason IO and web socket IO.
Now that I can target my iPhone and not the simulator. App on iPhone successfully does the http Json stuff but not the web socket stuff.
While I am not using safari and js my symptoms are very similar to yours. I am using Xcode 7 to generate code that targets to iPhone 5 using iOS 9.0.

"No route to host" error on iOS

I used GCDAsyncUdpSocket to send udp message to discover ssdp service, in iOS reported "No route to host" this error,but there is no problem in the simulator above can be found in service, is that how it happened? I searched a lot of information, but no discovery could help me.
I've run into the same thing. Of course without your source code we can't help you other than to provide vague guesses. I hope you've fixed it by now and if you recall what the problem actually was, please let us know.
Things to check :
Firewall settings on the host. I was trying to receive messages on my mac book and found that Firewall settings can block the port you chose. Firewall is under system preferences on the 3rd tab.
Use apples Reachability class to make sure you've got an active WIFI/Cell connection to the internet. (here : https://developer.apple.com/library/ios/samplecode/Reachability/Listings/Reachability_Reachability_h.html#//apple_ref/doc/uid/DTS40007324-Reachability_Reachability_h-DontLinkElementID_7 )
You can also use other functions in the Reachability class to let you know if the host is reachable before even bothering to open up a socket.
If the host is your mac and the simulator is on the mac, there isn't much of actual network traffic and then when you run on your phone you are actually using real networking. Be aware of, depending on your networking situation, you may need the external IP address of your host (vs the internal network WIFI address e.g. 192.168.1.4 )
Some people have reported a bug where UDP stops working and you get no route to host messages but for some reason turning on and off airplane mode fixes it. Maybe check out their solution (using keep alive messages ever 30 seconds or so to prevent power management from turning off the cell connection). Here is an example : intermittent "No Route to Host" on iOS, flight mode off then on fixes
In case you are developing an App Clip for iOS app, be aware that:
a) Background Session is not supported
b) Multipath is not supported. Setting `multipathServiceType = .handover` on `URLSessionConfiguration` will cause all requests failure due to `No route to host`

Blackberry http post request length trouble

I have a blackberry program that sends data using http post requests to a backend. Now the code works perfectly on my simulators (OS 5/6/7) and even on real devices, but on some other devices in some countries, the connection fails when using 3g with http error code 400 (Bad Request) but over WiFi it's ok.. After investigating, i realised that those telecom operators' bis-b proxies were "blocking"/"rejecting" the post request because of the size (>7kb). The problem is i can't shorten the request size, so any ideas on how to go about this? Any would be highly appreciated. Thanks
EDIT
This is the connection string used when connecting through the BIS.
deviceside=false;connectionUID=GPMDSXXXX;ConnectionType=mds-public (XXXX varies from network to network)
On further inspection, I realised that the "working" connections use the BIS_B TransportDescriptor type (5) to connect whereas the "failing" connections are using TCP_CELLULAR (1) to connect.
i.e. calling connectionDescriptor.getTransportDescriptor().getTransportType() for the working connections gives 5 and for the failing ones gives 1. Any ideas why this could be happening?
Try to use HTTPS. In this case carrier can't sniff what exactly is going inside.

How to make iOS believe there is Internet Connectivity

I am working on a web application for iOS that is going to be accesed from a local webserver in a network that has NO internet connectivity at all.
My problem is that everytime an iOS device is locked, it disconnects from the WiFi network, so when the device is unlocked again, it has to reconnect. Part of that reconnection process is determining if there is Internet connection (which there isn't). Until the process is not finished iOS does not allow any DNS resolution (so if I write http://10.0.0.1 it will go there, but not if I request http://something.local.com).
Since we control that network, we want to know how to does iOS verifies Internet connectivity so that we can fake the responses it expects.
I don't know if it's possible to resolve DNS without an internet connection on iOS, but if that's the case, that would be a way better solution since you don't need to mess with your router settings. Use my solution only if it really isn't possible with only code.
I'll suggest you to follow this guide: http://blog.jerodsanto.net/2009/06/sniff-your-iphones-network-traffic to check which actions your iPhone executes to detect an internet connection.
Using this information you could forward the is-there-internet-requests on your router to a local server which fakes the there-is-internet-responses.
This assumes Apple really uses an external server to detect this, which I'm not sure about. But it wouldn't hurt to give it a try!
Have you looked at the Reachability Class? You don't have to use the reachabilityForInternetConnection method, which checks if a default route is available. You can use the reachabilityWithAddress: method and check if your server is reachable.

Resources