Azure / azure-spatial-anchors-samples

Azure Spatial Anchors sample code
Other
293 stars 139 forks source link

Is it possible to configure a Proxy to be used by ASA SDK for network communication in Unity app #187

Closed TobiasPott closed 4 years ago

TobiasPott commented 4 years ago

Hello everyone,

I'm currently developing handling to increase resilience of an mobile app for iOS and Android using Unity, thus using the ASA SDK for Unity.

As we encountered problems caused by connectivity issues at our testing sites I've added proxy support for part of our application (Parse SDK) and used Charles Proxy to throttle network throughput and stability to reproduce problems. Now we still encounter problems, of which we are not sure whether or not they are caused by network issues or by another reasons. These problems arise from the ASA SDK and I want to narrow down and be able to reproduce issues caused by connection problems.

Unfortunately I couldn't find any documented methods to configure a proxy to use by ASA and wondered if there is any way to do so. I'm aware of the possibility to configure a global proxy for .NET using the WebRequest.DefaultWebProxy property, but this does not apply to the native code from the SDK.

I'm aware that I can configure a proxy for the WiFi the devices use, but I cannot tell whether or not the traffic generated by the ASA SDK is going through my Charles Proxy installation. Previously using only the WiFi Proxy didn't cause our Parse SDK to use it, thus I cannot tell if ASA SDK would do. Anyway, I get requests going to https://mobile.events.data.microsoft.com and https://sts.mixedreality.azure.com (aside from a whole bunch of other requests to Unity servers which clutter my recorded sessions) but I cannot tell if that are URLs the SDK should communicate with and does so for the actual 'magic' of anchor recognition or if it is only logging and diagnostics.

To put it short. Is there a way or could one be added, to allow me to configure a proxy to route the traffic through? Can someone confirm or refute whether or not the urls mentioned above are related to the anchor recognition of the ASA SDK?

Thank you in advance, I'm eager to get any input on this issue.

Kind Regards Tobias

chwarr commented 4 years ago

Briefly, no, there isn't a way to proxy the connections that ASA uses with a HTTP proxy. Most of the ASA communication uses a custom protocol that we run over TLS on port 443.

TobiasPott commented 4 years ago

@chwarr Thank you very much for the fast response. So I'm not that deep into the networking stack and may misinterpret your statement but it sounds to me that it might be possible to proxy the communication if I get some sort of TCP proxy inbetween our devices and the rest of the internet? Please correct me if I'm wrong.

And another, maybe naive, question, would it be possible SDK-wise to add the option to configure a proxy for the ASA communication in the future? (to put anything like nginx or toxiproxy inbetween it for resilience testing) Or is there a way to suggest or request features?

Kind Regards Tobias

chwarr commented 4 years ago

Yes, a TCP-level proxy should work if you can get it hooked in at the OS level or by using, say, a dedicated WiFi network that you control. There's no way to tell the ASA SDK to use any sort of proxy.

You may also want to look into other ways of shaping the traffic especially for testing. On macOS, the Network Link Conditioner can be used, for example, to simulate a 3G connection.

We use the Azure Feedback Forum for feature requests for Azure Spatial Anchors. You can view and vote on existing feature requests and submit your own.

TobiasPott commented 4 years ago

Oh I wasn't aware of the forum (or forgot about it). Thank you for the link to that.

Yes I'm aware about the Network Link Conditioner and the developer options on iOS. Though we would need a iOS and Android solution and Android does not seem to have such neat developer options. But I'll take the TCP-level proxy and suggest it for discussion as it will definitively come in handy for other projects and general platform-independent testing.

Thank you very much for your response. =) I'll consider this case answered/closed and providing sufficient information about the alternatives and options available.