ios https fails if I switch from wi-fi to 3g - ios

my problem is about not being able to access an https server after switching from wi-fi to 3g.
The error I get is Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server.
i tried the same thing using ASIHTTPRequest and AFNetworking libraries, both have the same thing.
i'm guessing the problem is about trying to use the same ssl credentials even though our ip is changed as a result of network switching. strange enough, this problem does not happen if you switch from 3g to wi-fi.
some notes:
i'm using an iphone 4 device.
device has ios 6.0 installed.
server side has apache php installed.
has there been somebody encountered this before? can i somehow clear any stored ssl credentials on ios cache? any thoughts on the subject?

The problem turned out to be a dns issue. Somehow working ip address was cached in wifi network but not in 3G network I think.

Related

Charles Proxy not working on Mac with iPhone

I am trying the proxy the network traffic from my iPhone to Mac via Charles Proxy, below are the versions i am using:
iPhone - model 13, OS - 15.4
Mac - OS - Monterey (12.2.3)
Charles - 4.6.2 (licensed)
I installed Charles on Mac, enabled SSL Proxying, added generic IP (0.0.0.0/0) in Access Control Settings, got the local IP address from Help and used it on my iPhone wifi settings - Proxy > manual > local IP from Charles and port 8888.
As soon as i do this my phone is not able to connect to internet at all. I have seen various instructions about adding root certificate, enabling trust settings etc, but those all can be done only if am able to connect to internet to download the certificates. Which i am unable to.
I went through every question on this site which mentions Charles proxy, but none could provide any solution to my problem so appreciate any inputs on this.
If there is no important information in your phone, you can reset the network settings first, then try the following
Make sure that both the computer and the phone are not using a virtual private network
The computer and the phone are in the same network environment
The computer has the Charles root certificate installed
The phone has successfully installed Charles' certificate and trusts it.
If the above suggestions don't help you, I suggest starting from scratch and troubleshooting the problem step by step
Let's take mobile phones and computers accessing https://www.google.com separately as an example
After the computer installs the certificate, can it be connected to the Internet normally, and can it crawl Google's response request?
The mobile phone and the computer are on the same network segment and use the proxy URL provided by charles. Can you access and download the certificate?
3. On the computer, does Charles pop up an access prompt and ask you to choose whether to agree to the access?
Turn off the computer-side crawling and access it on the mobile phone to see if it can crawl the response request on the mobile phone.
Next time, check the firewall in the security and privacy settings. It should not block Charles' incoming connections. I spent two hours trying to figure out what was going on

How to make a request to localhost via iOS device (using Xcode)?

I have a localhost website up at localhost:1336. When I run it on my simulator using Xcode, the app does not encounter any problem make a request to the localhost for data. But when I connect my iPhone via USB cable to the mac, and run the app on the iPhone device and makes the request, but then I get an error "Error- Could not connect to the server.".
I also confirmed that they are on the same Wi-Fi and using same IP. On Safari on my iPhone, I went to http://IPNumber:1336 and it was able to access the site via my iPhone. But some reason, through the app, it cannot connect to the server.
Any input or insight on this would be greatly appreciated. Thank you in advance.
the term 'localhost' means the same device, i think you mean a host on your local network? going localhost:1336 means your device is connecting to itself, its the same as going 127.0.0.1:1336. hence why it works on your simulator but not your phone, since your server and simulator are running on the same device
you have to use http://IPNumber:1336 in your app as well
"Localhost" means the same device. If you are not running a HTTP service on your iPhone, you should not use "localhost".
Another point, you are using "http", if your iPhone is running iOS9+, you will need to check whether App Transport Security will be an issue, here is an article on how to do that: http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/

iPhone connection to localhost rails sarver

I am creating Rails server for iPhone app.
I want to debug on iPhone device not on iPhone simulator.
So, I connect iPhone to mac book air by USB, and connect to Rails server.
But, iPhone could not connect to Rails server.
Environment
Rails 4.2.3
Server localhost:3000
Xcode 6.4
iPhone iOS 8.4.1
en0 inet 192.168.11.7
As long As I searched, when iPhone device connect to localhost server, the url is http://192.168.11.7:3000/~.
But, mac console show nothing and xcode show "The request timed out." after a while.
If anyone know how to fix the problem, please tell me.
Use the wonderful http://xip.io/
You don't need to install anything - just go to
http://192.168.11.7.xip.io:3000
on your phone.
If you want to use a particular domain name, eg if your app behaves differently depending on domain names or subdomains, you can do eg
http://mydomain.foo.192.168.11.7.xip.io:3000
EDIT: my answer is actually about connecting to your server over the internet rather than a usb cable. I'd recommend that you use the internet rather than the USB option if possible as it's simpler. xip.io will not work if you can't access the internet.
You probably tried that but funny enough, in my case turning my iPhone off and on again actually fixed the issue.
I had the same problem, my app was working fine and all of a sudden it stopped working although nothing had changed. I could access the internet, the browser was accessing the rails app url just fine but my iOS app did not seem to be able to connect to it.
I needed to run my iOS app from Xcode with my local rails server to my device and xip.io was the solution.
Get the ip address of your computer from the wireless network you are connected to and put that into networking.swift like so.
http://11.1.11.100.xip.io:3000
Make sure the rails server is running and your device is connected to the same network as your computer and build the app.

TCP connection not working properly when using iPhone as hotspot

I'm developing an application for iOS which is connecting through TCP sockets to a server aplication run on Android. In order to find the IP of the 2nd device I use a UDP request and receive the IP of the server.
It's working well all the time when I'm connecting them to Wi-Fi network or when I use the Android device as a hotspot to the iPhone. But if I want to make the iOS device a personal hotspot, I can't reach connection between the two devices and the app is useless in this regime. Is it possible to connect the devices then and is the algorithm the problem? I would be glad to hear if someone has ever had a similar problem and knows the solution.

Flex iOS application with rtmps

I am trying to connect to an rtmps endpoint in AIR.
The code looks like this:
private function onCreationComplete():void{
var conn:NetConnection = new NetConnection();
conn.connect("rtmps://someserver.com/someapplication");
conn.proxyType = "best";
conn.addEventListener(NetStatusEvent.NET_STATUS,statusHandler);
}
private function statusHandler(event:NetStatusEvent):void{
var conn:NetConnection = NetConnection(event.target);
trace(event.info.code);
}
This actually works perfectly when running the app on the desktop in ADL (emulator).
However when I install the application (.ipa) on the iPad, the connection fails.
Both my desktop and the iPad connect to the same wireless network (thus use the same network architecture to connect)
Has anyone experienced this kind of behaviour before?
Cheers
This is still a problem with Air 3.1.
I have raised a bug report with Adobe - https://bugbase.adobe.com/index.cfm?event=bug&id=3133542
After some serious efforts to figure out what was wrong here,
We were unable to establish a connection to our server via rtmps.
Regular rtmp seems to be fine but is not unfortunately not an option for us.
*EDIT*
This problem was solved in the AIR 3.1 release.
Turns out connecting via WIFI + Proxy via RTMPS was failing for iOS.
Check out the AIR 3.1 release notes for more information on this.
We establish connection to the server only through the RTMP protocol.use rtmp instead rtmps,the connection can be established.

Resources