A single case of Safari on iOS9 not connecting to websocket - ios

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.

Related

iPhone sending Encrypted Alert packet

Background: I have created a hybrid app in angular using the capacitor library. Everything is working well for the browser and the android mobile app and the iOS mobile app. On the backend, we are using hardware that is acting as a server. The hardware and our mobile are connected to the same router and we are accessing the hardware using an IP address. Also, we have added a self-signed certificate on the hardware and are using HTTPS while communicating with the hardware.
Bug: The only issue we are facing right now with the iOS app is its slowness. I did some digging around the frontend using Wireshark and came to a point where the iOS app is sending the acknowledgment packet followed by an encrypted alert packet when it receives a response from the server. This is happening for every request. After further debugging on the server end I came to know that once it receives an encrypted alert it is closing the socket. Then again it is performing session handshake, opening the socket again and then processing the request. So, basically, the below process is repeated every time:
Performing session handshake
Opening Socket
Processing request
Sending response
Closing the Socket
On the contrary, on an android device, this process is only happening the first time it sends the request and then data transmission is taking place without closing the socket.
Below are the screenshots of Wireshark for Android and iOS:
iOS Screenshot:
Android Screenshot:

iPhone network requests are not working sometimes

In my app I'm using MKNetworkKit to make requests to my server and also make direct calls to Facebook using Facebook SDK. Sometimes (once in a few days) I get an odd issue: all network requests from my app stop working (both to my server and Facebook). I can't figure out what steps exactly cause this. When I have the issue I check other apps / Safari from my phone and internet connection is OK. If I close my app, wait for a couple of minutes and open it again then everything goes back to normal. I'm using WiFi for testing. What can cause this?
It seems to be exactly like in this question: iPhone app gets into a state where network requests never complete , although I don't use MonoTouch.
UPDATE:
I do receive callbacks from MKNetworkKit saying "Request timeout" (I have 10 seconds request timeout in MKNetworkKit settings). And I don't receive callbacks from Facebook.

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.

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

getting IOException : Peer refused the connection (BlackBerry)

Can anyone tell me why i am getting this IOException:smileytongue:eer refused the connection??? I was testing my application yesterday it was working fine..but today when i opened it i cannot log int my application...i cannot login from the simulator.
.i hve tried appending ";deviceside=true" , ";deviceside=false" and removing it from the url..but nothing seems to work even on simulator...Iwas able to login until yesterday...no change in the code has been made...
The login url is Https url..but i dont think that may be the issue since i was able to access it till yesterdey...
Can any one help..??
I'd double check that the server you are talking to is still up (can you connect to it from a browser on your computer?) and also ensure that the Windows Firewall is not blocking traffic from the simulator. Also, unless you're just using Direct TCP and/or Wi-Fi, make sure that MDS simulator is up and running BEFORE you launch the simulator.

Resources