NSURLErrorDomain when try to connect to camera using API v. 2.1

Hello!
We are developing iOS mobile app that uses Ricoh Theta API v.2.1. Some of our customers complains that they can’t take photos using our app though it works fine when they use Theta mobile app.
We can’t reproduce it, but maybe there is a chance you can advice to us something.
We have added logs and see that for our customer the request POST http://192.168.1.1/osc/state fails with the following NSURLErrorDomain error .

[23-09-26-14-57-52]: [RicohCamera::OSC]: <Api.Query.Task
	"CreateAt": "2023-09-26 18:57:50 +0000"
	"Duration": "2s"
	"Request": <URLRequest
		"URL": "http://192.168.1.1/osc/state"
		"Method": "POST"
		"Headers": {
			"Content-Length": "0"
		}
		"CachePolicy": "UseProtocolCachePolicy"
	>
	"Error": <Error
		"Domain": "NSURLErrorDomain"
		"Code": -1004
		"UserInfo": {
			"NSErrorFailingURLKey": "https://192.168.1.1/osc/login.html"
			"_kCFStreamErrorDomainKey": 1
			"_kCFStreamErrorCodeKey": 61
			"NSUnderlyingError": <Error
				"Domain": "kCFErrorDomainCFNetwork"
				"Code": -1004
				"UserInfo": {
					"_kCFStreamErrorCodeKey": 61
					"_NSURLErrorNWPathKey": "satisfied (Path is satisfied), viable, interface: en0[802.11], ipv4, dns"
					"_kCFStreamErrorDomainKey": 1
				}
			>
			"NSErrorFailingURLStringKey": "https://192.168.1.1/osc/login.html"
			"NSLocalizedDescription": "Could not connect to the server."
		}
	>
>

Additional info from customer:
Camera: Ricoh Theta SC2 for business
Camera’s serial #YP40133479
Camera’s firmware version: 6.52
Devices: Iphone 14 and iPad 9th Gen 10.2-inch
iOS version: 17.0.1
Steps we have tried to fix it:

  • Everything is up to date
  • Reset network settings
  • Reset camera
  • Granted permissions “connect to devices on your local network” permission
  • Uninstalled/reinstalled the our app app and enabled permission again
  • Checked local network settings for our app and it’s enabled

What is https://192.168.1.1/osc/login.html?

The camera endpoint is a http, not https, right?

How is that URL getting introduced into the log? Is it from the camera?

This person solved the problem by switching the HTTP library to make the request .

@Mikhail I’m curious about headers. I don’t have total confidence here, but have you set

Content-Type to application/json;charset=utf-8

not text/json

Hello Craig! Thank you for your response.

What is https://192.168.1.1/osc/login.html ?

According to our logs we got this in response of the request POST http://192.168.1.1/osc/state. I am not sure that this is from the camera, maybe it’s some iOS restrictions and iOS doesn’t allow to connect to Ricoh server

The camera endpoint is a http, not https, right?

Right, we use http, not https.

I’ve read the thread you mentioned and I am wondering maybe we should specify some values inside NSAppTransportSecurity dictionary in info.plist?
Please see all possible keys for this dictionary:

NSAppTransportSecurity : Dictionary {
    NSAllowsArbitraryLoads : Boolean
    NSAllowsArbitraryLoadsForMedia : Boolean
    NSAllowsArbitraryLoadsInWebContent : Boolean
    NSAllowsLocalNetworking : Boolean
    NSExceptionDomains : Dictionary {
        <domain-name-string> : Dictionary {
            NSIncludesSubdomains : Boolean
            NSExceptionAllowsInsecureHTTPLoads : Boolean
            NSExceptionMinimumTLSVersion : String
            NSExceptionRequiresForwardSecrecy : Boolean   
            NSRequiresCertificateTransparency : Boolean
        }
    }
}

I can ask our contacts at RICOH to see if they’ve seen this behavior before or have any advice. I suspect that unless it is a common problem, it will be tough to get proper advice as it will be difficult to replicate the problem.

There are many errors of this type on the apple developer forums. This one below indicates that a problem was occurring when switching between https and http. Although there is no solution posted, it may provide a clue as to how to replicate the problem.

https://developer.apple.com/forums/thread/672275

Are you pushing the images up to the cloud using mobile data while the SC2B is connected to the iPhone with WiFi?

Are you pushing the images up to the cloud using mobile data while the SC2B is connected to the iPhone with WiFi?

No, we don’t do it.

We just tried to add NSAllowsArbitraryLoads = true and NSAllowsLocalNetworking = true in our info.plist and sent the new build to our customer who has this problem. I will keep you posted if it helps.

I can ask our contacts at RICOH to see if they’ve seen this behavior before or have any advice.

I believe it can be really helpful if they could provide what they specify for NSAppTransportSecurity in their info.plist for the Theta app. Thank you in advance!

Hello! Just want to update you that setting NSAllowsArbitraryLoads = true and NSAllowsLocalNetworking = true in info.plist didn’t resolve the problem for our customer.

Sorry, missed your post. Yes we set Content-Type to application/json;charset=utf-8.
Everything woks fine for 99% of our customers and for all our devices in development team. But 1% of customers complains because of this error

OK, thanks for confirming. And thanks for the information on how often it occurs. I will report this back to RICOH.

@jcasman , I’m rather puzzled by the error below. I don’t know why it would show
"https://192.168.1.1/osc/login.html"

We can try Google searches on this type of behavior for iOS development in general. If that is coming from the THETA SC2B, it may provide a clue as to the source of the problem.

The theta-client has a demo for iOS Swift.

Is it possible to test theta-client demo-ios and see if the error can be replicated?

If the error can be replicated, you can then open an issue on GitHub for assistance.

<key>NSAppTransportSecurity</key>
<dict>
		<key>NSAllowsArbitraryLoads</key>
		<true/>
		<key>NSAllowsLocalNetworking</key>
		<true/>
</dict>

For some reason, this is coming up on your app. The URL does not seem to be coming from the RICOH THETA.

"NSErrorFailingURLStringKey": "https://192.168.1.1/osc/login.html"

Hello Craig! We set the same options in info.plist as in Ricoh Demo app and it fixed the customer issue. We will observe the other customers and let you you know if it happens again. Thank you very much for your assistance!

1 Like

Thanks for letting us know the status. I noticed that the ricoh app also has
<key>NSAllowsLocalNetworking</key>

Hi @craig ! One of our customers again experiences this issue. According to his words he has started to get this errors after updating to iOS 17.4. Do you maybe know if there are some changes that’s need to be done (though can see no changes in this repo theta-client/demos/demo-ios/SdkSample/Info.plist at main · ricohapi/theta-client · GitHub )
Please also see logs that we were able to collect from the customer:

[24-03-14-14-13-12]: [RicohCamera::OSC]: <Api.Query.Task [
	CreateAt: 2024-03-14T14:13:12-0700,
	Duration: 0s,
	Request: <URLRequest [
		URL: "http://192.168.1.1/osc/info",
		Method: "GET",
		Headers: [
			"Content-Length": "0"
		],
		CachePolicy: UseProtocolCachePolicy
	] >,
	Error: <NSError [
		Domain: "NSURLErrorDomain",
		Code: -1004,
		UserInfo: [
			"_kCFStreamErrorDomainKey": 1,
			"_kCFStreamErrorCodeKey": 61,
			"NSErrorFailingURLKey": "https://192.168.1.1/osc/info",
			"NSLocalizedDescription": "Could not connect to the server.",
			"NSErrorFailingURLStringKey": "https://192.168.1.1/osc/info",
			"NSUnderlyingError": <NSError [
				Domain: "kCFErrorDomainCFNetwork",
				Code: -1004,
				UserInfo: [
					"_kCFStreamErrorDomainKey": 1,
					"_NSURLErrorNWPathKey": satisfied (Path is satisfied), viable, interface: en0[802.11], ipv4, uses wifi,
					"_kCFStreamErrorCodeKey": 61
				]
			] >
		]
	] >
] >

@Mikhail I’m going to meet with a person I know at RICOH today and will report this.

“NSErrorFailingURLKey”: “https://192.168.1.1/osc/info”,

The URL should be http, not https

Is it possible that somehow a portion of the code is trying to use https?

image

@craig I m also facing the same issue… tried all above solution but still getting same error.
1.Error 1:**

Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." 
UserInfo={
    _kCFStreamErrorCodeKey=61, 
    NSUnderlyingError=0x2800e13b0 {
        Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" 
        UserInfo={
            _NSURLErrorNWPathKey=satisfied (Path is satisfied), 
            interface: en0[802.11], ipv4, dns, 
            _kCFStreamErrorCodeKey=61, 
            _kCFStreamErrorDomainKey=1
        }
    }, 
    _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <8409EE14-264C-4B78-9FAD-845E0A1C10DB>.<1>, 
    _NSURLErrorRelatedURLSessionTaskErrorKey=(
        "LocalDataTask <8409EE14-264C-4B78-9FAD-845E0A1C10DB>.<1>"
    ), 
    NSLocalizedDescription=Could not connect to the server., 
    NSErrorFailingURLStringKey=https://192.168.1.1/osc/info, 
    NSErrorFailingURLKey=https://192.168.1.1/osc/info, 
    _kCFStreamErrorDomainKey=1
}

hi @Craig any updates on this.

Sorry, I don’t know how to solve it. Unfortunately, I am not familiar with iOS development and don’t have an iPhone that I can use.

You best bet is to try and open an issue on the theta-client GitHub repository.

You can also research on Google about why the application is changing the URL from http to https.

Without knowing too much about iOS development myself, I’m wondering why the URL gets changed from http to https. It will fail if it tries https.

1 Like

@Anjali_Nirmale I will include a summary of your issue and the error messages you provided in the agenda in our weekly call with RICOH this week. I do not know if RICOH will provide an exact response. But I will report back here any information that I find out.

Confirming: You said that connecting to your X and using the RICOH THETA mobile app works fine, correct?

At the same time, you can create an issue on the RICOH repo for theta-client. You may get a response there.

1 Like