About Huawei Mobile phone mobile 4G cannot be connected to the problem

Source: Internet
Author: User

Background: In the development of applications, there has been a strange phenomenon, that is, some of Huawei's models, mobile 4G cmnet, unable to connect to the network, after the problem of research and resolution, just triggered this blog thinking and learning, here with you to share.


Test case: (Huawei Meta 8,meta 7,P8,P9 6.0 machines have this problem)

 

Mobile 4G (CMNET)

Mobile 4G (Cmwap)

Telecom

Unicom

Wifi

We apply the domain A

Other domain names that we apply

(There is also a case is Shanghai mobile 4G can, but Beijing and Tianjin can not)


You see the above case, the first reaction should be mobile operators or our own domain name of the server problem.

The problem arises, the server is receiving our request, and has returned the message, but the client is a timeout.


Combined with the above analysis,

I thought of it.

The first idea is to grasp the TCP IP packet for analysis, the results blocked. (The reason is that the machine is 6.0, and it's not root at all)

The second idea is whether you can grab the bag through the agent, the result is mobile card recurrence, no root, this path is not.


At the end of the day, I and another colleague, at the same time by writing a demo of their own client network request, the result of his is OK, I wrote the demo can not.

So I think it's about the code logic that the client writes.

I will be all the network request framework to write a demo, this kind of thing network find a lot of, casually find a change, you can use, basically have no time consumption.

The test results are as follows:

URLConnection

Java.net.ProtocolException:unexpected End of Stream

HttpURLConnection

Java.net.ProtocolException:unexpected End of Stream

HttpClient

Ok

Volley

TimeOut

Abstracthttpclient/defaulthttpclient

TimeOut

Okhttpclient

Ok

This feeling a bit boss, not big, will we use the Volley network framework completely changed to the other two can run the network framework is OK, but the price seems a bit big ah,

Let's start with a minimal change to the problem-solving scenario,

This is the need to intercept the packet, compared, although the mobile network does not work, but WiFi and mobile we send the request must be the same.

Grab it. The results are as follows:


The effect of using okhttp truncation is as follows:

The effect of using volley truncation is as follows:



After comparing with several other access network requests, the discovery can request, uses is own user-agent, the request which cannot access the network agent All is uses the Huawei agent,


So I suspect that the agent is involved, so the user-agent of the volley package is modified to the other agent.

			@Override public
			map<string, string> getheaders () throws Authfailureerror {map<string
				, string> headers = Super.getheaders ();
				if (headers.size () = = 0) {
				<span style= "White-space:pre" >	</span>headers = new hashmap<> ();
				<span style= "White-space:pre" >	</span>headers.put ("User-agent", "okhttp/2.5.0");

				return headers;
			}

The result is OK, really burst into its surprise.

Well, the final plan has, at the very least, can be solved.

There is still a need to continue to analyze why.

Because the understanding of this agent is the statistics who request, is the browser, or a client, theoretically should have no effect ah, so we need server-side help.

Results analysis, found that the server side if the direct access to IP is available, and timely access to the domain name, there is a certain probability can be used. Just timeout time needs to be set very large,

So I think it may be related to some of the server's machine, originally intended to be in the server to grasp the package to deal with, but a designated to a certain machine IP time, it can be used, and disconnected,


Consider two factors: 1. The client can fix it, and hot patches can solve the problem quickly

2. The investigation of this matter is too time-consuming, the project is also more nervous,

So there's no further trace analysis.


This time, I will continue to find relevant information to analyze the root cause of the problem.

That's the way it is now,


Here to contribute to my various network request Access Demo:https://github.com/xiepengchong/networkdemo

I also find on the Internet, modify the acquisition, take the net, feed to the net.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.