Network Agent Setup Android development summary

One, background

When Android project development, network with agents basically deal with every day. Typically, there are at least three scenarios frequently used network proxy:
1, frequently visited by Google Chrome and other foreign technology Web site, such as by SS tools;
2, AS (Android Studio) is required to download aar abroad or jar package and other resources;
3, when the phone capture, such as Charles turned capture software on your computer, mobile phone connected to the computer network packet capture software corresponding proxy.

Whether using SS, or pull resources by AS, and Charles packet capture, etc., sometimes we will encounter some "inexplicable" network problems. Solving problems, it may sometimes inexplicable good, and sometimes may take a long time we are unable to solve. Especially when these three tools simultaneously. The reason is that this whole process for the network proxy did not find out, and there may be between them will affect each other, problems may arise at this time helpless.

Second, the network proxy process

Project development process used browser Ye Hao, AS worth mentioning, the broad category belong to the application layer software. In the process of software implementation, based on the actual situation, the system may have a network proxy to determine if there is a proxy, the proxy to go. Even provide external settings, such as AS, Chrome can go to a separate configuration for network proxy. Once configured, it will be based on the specific circumstances, combined with their own software configuration and system network proxy to go network. Of course, some software, and it does not judge the system network proxy, in which case, no matter how the system network proxy settings, or go directly to the default network process.

At the same time, different network proxy configuration, the impact of the software is different. For example, if the system is set up FTP proxy, it may only result in possible impact on the use of the FTP protocol related software, just using the HTTP protocol software is not affected. However, if the system is set up TCP proxy, at this time, located to the HTTP protocol using TCP protocol software upper application layer, it is also likely to be affected. Because, HTTP layer will still be transmitted to the network via TCP layer.

In general, the overall process is like.

 

Network proxy settings of the operating system interface, provided by a corresponding software agent, the agent may be configured to specific network information. Other network application layer request, after reaching the operating system will be based on specific network proxy settings, decide whether to take the network proxy, and specifically how to take the process of the network.

In SS (Shadow ** Socks) as an example, the installation of the SS, from the perspective of other application layer software in effect, the layer belonging to the Server, as all native Client requests will eventually be forwarded by the SS. On the other hand, the overall architecture of the agent from the SS, the SS installed the machine, but belongs to the SS Clinet, because there is a corresponding remote SS Server. Native Client request via the machine after the SS Client forwards, will reach the designated SS Server, SS Server get the request, deblocked, to give the actual request information forwarded to the Remote Server, and the request corresponding to the result obtained after packaging Client response to the SS, the corresponding, native post-processing back to Client applications.

Therefore, if a problem occurs after the network proxy settings, the overall judging process is like this:
1, with or without network proxy software to set up a network proxy;
2, if set, specific settings are the way you are, but for what the network protocol settings;
3, whether the network proxy software settings to take effect (from the 系统偏好 >> 网络 >> 高级 >> 代理view go);
4, other application layer software support for the network agent (depending on other application layer software itself whether there is a separate network proxy configuration, and network proxy the protocol level);
5, if there is the effect of the expected impact on other application layer software.

This is one of the most critical points are: 具体的网络代理设置and 其他应用层软件对网络代理的支持.


Third, the network agency practice

Different network proxy software, there are different setting methods. SS PAC may be provided, for example, an automatic mode, whitelist mode, the global mode. PAC whitelist mode and automatic mode, an update down the list of domain names or arrangements, to decide in the end whether to go forward native of network requests by SS. Global mode directly Socket Layer proxy, Http access to the top, it will take effect. Therefore, if you set a global model, the performance will be whether it is access to multiple sites within a site or abroad, will go forward network requests by SS. But there is a place that needs attention, global mode settings, in fact corresponds to the system default Http proxy, Https proxy agents and Sockes, if the browser itself has a separate proxy configuration, such as configured PAC model, the actual access website process, taking the process will be PAC mode, even if the browser ignored the system network proxy, go directly to the direct connection mode, at this time, the network proxy settings are invalid.

Under can actually test system on SS global proxy, the proxy settings we look at the results detected by the system:

Which, IP from Australia showed that SS Server Access Remote Server export IP address.

 

Open a new Chrom, SwitchyOmega choose to go through the system proxy, ip access detection results obtained by the website:

SwitchyOmega switch to PAC (needs to correspond configured), results showed that:

 

At this point, if we open the new AS, result in Preference >> Http Proxy settings, see:

 

We found that, at this time SS global network proxy mode settings on the system, and the AS has had an impact (although AS itself at this time did not set up a proxy). For example resources under aar download network will fail.

If SS mode are subject to change at this time need to restart AS, or even kill the java process to see the above warning disappears (because of the existence of the cache).

Of course, also be Gradle for individual items or Gradle globally, by gradle.propertiesway of the configured network proxy settings. Such as the common:

systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=1087
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=1087
复制代码

There is also a very easy experience, but overlooked point is that when you turn Charles capture software, by default, is to start the system agent that Proxy >> macOS Proxydefault is checked.

At this point, Charles equivalent proxy settings software automatically set the system Http and Https proxy at startup. In this case, the machine corresponds to the presence of a plurality of networks at the same time the agent software, and at the same time the proxy network configuration, the end result, the effect will be covered (after the first start and if enabled for the same protocol set , whichever is later enabled). In any case, this time often also affect the AS, for example, can not find the certificate, or download failed aar resources and so on.

Previously, when AS development projects, just met Charles capture, agency problems caused incomprehensible for a long time.

Of course, the system is enabled by default when Charles start the agent can cancel the. Specific path in Proxy >> Proxy Settings >> masOSthe set.

Actual development, the impact of setting the AS SS generally known, but the system is turned on by default when Charles capture agent is covert, often causing distress.

No matter what kind of agent software, which set up the proxy mode, set both enabled, the final results are available in the proxy 系统偏好 >> 网络 >> 高级 >> 代理to see in. But the process used by other applications layer software, may cause some inexplicable problems. In this case, after the network proxy settings are correct manner, often by restarting the software even deleted the corresponding process, etc. can be resolved.


IV Conclusion

Different network proxy software, you can set different network proxy effect, but on the whole, the Network Agent processes are similar (of course, Charles as a network proxy, it does not actually exist Proxy Server, but as an intermediary to forward the request to the network ).

In the case of the machine there are multiple simultaneous use of agent software, other software will often affect the application layer. In this case, the results need to carefully sort out a final proxy settings of the network, as well as other proxy configuration software itself, to judge and comprehensive process.

end~


Author: HappyCorn
link: https: //juejin.im/post/5d6a2fa26fb9a06b102740eb
Source: Nuggets
copyright reserved by the authors. Commercial reprint please contact the author authorized, non-commercial reprint please indicate the source.

Guess you like

Origin www.cnblogs.com/lwbqqyumidi/p/11991813.html