Blackberry http post request length trouble - blackberry

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.

Related

Http request (GET) timeout sometimes and I want to find the cause

I am developing an iOS app that makes an API request to my server hosted in Heroku.
In my slow internet connection environment, the API request (via Http Get) sometimes results in a timeout. The response time is usually 2000 ms if not timing out.
By "sometimes", I mean about one in 10 requests times out (I do not get any meaningful error code).
I also tested this timeout with 2 devices. When one device is waiting for the server to respond for longer than 2000 ms, I use another device to call the api, to which the server responds normally. But the first device still results in a timeout.
I am not quite sure what is to blame here. My internet connection? My api server on Heroku? I also tested this timeout on Postman and got the same results.
PS. I am based out of Bangkok. The ISP with which I experience the most timeouts is True Broadband.
Any and all advice is appreciated.
Thanks in advance
PPS. In response to comments warning that the question is too broad: Let's ask it this way. If our api calls randomly time out, how can we detect whether it is due to a slow internet connection, or if the fault lies in our own server (or something else)?

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.

BlackBerry Connection issue : Cannot open any more tunnels

I get this error when i try to authenticate via OAuth, i am able to use the connection factory to access unauthenticated requests. It works fine on the simulator but doesnt work on the device. It worked once or twice on the device but fails consistently every other time.
I have tried manually setting the APN on the phone but still unable to connect, while other requests successfully execute.
I am using the Connection Framework from BB OS5 and higher, so the connection was not the problem. The GET and POST requests worked well over the simulator but the POST request failed on the phone, while the GET request worked on the phone. The problem was a simple error in the POST request, i set the content length to just account for the URL instead of also the data being sent. I simply removed the content length in the POST URL and all was ok.

How can you tell if the iPad has WiFi connectivity programatically?

When my iPad application makes a web request using the ASIHTTP library it will fail if there is no internet connection.
I want to identify specifically when there is no internet connection and show a unique error to the user (vs. just identifying that the call failed which can happen for a large number of reasons: e.g. The target website is down.)
I've noticed ASIHTTPRequest returns a Status Code 0 when there is no Internet Connection available. If the webpage is not available or another error occurs in communication with the server, it returns an actual HTTP Status Code.
In this case, You could just check to see if request.responseStatusCode == 0 is true and act on that

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

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!.

Resources