Wednesday, February 26, 2014
100 first aid, http request no response, experts into
Be weather forecast demo, found online China Weather Network API, which http://m.weather.com.cn/data/101020100.html this address can be on pc browser to directly access, get a json of data. Usually such requests directly on the Android pass url into it, get a way with a request you can get the json data. But I this is not connected, log is simply a timeout. I think it should be two domain name can not be resolved, because there are two API, is the top-level domain, you can get directly to the data, this does not work. But why the pc can do.
org.apache.http.conn.ConnectTimeoutException: Connect to / 61.4.185.34:80 timed out
Beg cattle exhibitions<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Beg big Niua emergency ah
Reply:
Code which calls the URL is incorrect reasons for it.
Look up the error message you send is the IP: 61.4.185.34, and you said that URL IP is: 113.108.239.107
URL corresponding IP with the IP you an error message is different, it is estimated that the code inside your web site is another call.
Reply:
Permission to add it?
Reply:
I do not know how else ah, I'm sure that the address is a copy from the code inside out and then stick to the pc browser json data can be obtained directly on the pc, the phone will not connect. In addition, the permissions are added.
He also has two API, are top-level domain http://www.weather.com.cn/data/cityinfo/101020100.html this directly copy the code can request data. And replaced http://m.weather.com.cn/data/101020100.html to die. I do not know how it is, is it not DNS?
Reply:
I suggest you first try it in the simulator, simulator and PC with the same network, if the simulator is also wrong, it can only be said that your code has a problem.
Also recommended code check, see URL before clicking Get used Log output is correct.
Reply:
Very happy ah, let me see hope.
Be able to get the simulator data. But why not do it on the phone?
I suspect that the domain name resolution on the phone with pc not like him this is a second-level domain, and I suspect this is the problem, do not know if anyone knows how to engage.
Reply:
Your mobile phone network is good
Reply:
You tried to help telecommunications network phone normally.
This case the operator to find it, as far as I know some parts of the country and China Unicom mobile operators only allows the user to specify a number of websites.
Reply:
Http you have not set the timeout? I tested, it can access and get json data.
Look at your httpclient settings.
CONNECTION_TIMEOUT_MS = 30 * 1000;
HttpConnectionParams.setConnectionTimeout (params, CONNECTION_TIMEOUT_MS);
HttpConnectionParams.setSoTimeout (params, CONNECTION_TIMEOUT_MS);
If not enough, that is a question of your network
Reply:
Reply:
Timeout set of 50000, ah, this is not a problem given the pit. Could it be a network problem, so I try to use the phone colleague
Reply:
No mobile phone network, the simulator will do
As long as the computer can open, there would be no problem
Reply:
That how to engage someone encountered this problem yet. Write a program, not some mobile phones can be used, some phones can not use it. To GM ah, this should be resolved, seek expert ah
Reply:
So why ink weather and some weather widget can it? They also used a similar approach, right?
The landlord can put code stickers, everyone analysis, let us learn together and progress
Reply:
The URL
http://m.weather.com.cn/data/101020100.html
Replaced by:
http://113.108.239.107/data/101020100.html
Try
Reply:
Thanks so much, how I did not expect it. Ha ha.
This done so I can open source oh.
Scattered points, thank you, everyone has a point
Reply:
But you have to consider the case of IP has changed on the day and not be used, previously done similar applications,
Unicom's mobile phone can not access a Web site A, the solution:
The default is the first access to the specified URL A, if you can not access it, then re-visit a Web site its own web page B, your own web pages using asp write this, the function is to read the contents of the Web site A and displayed.
In this way, most of the mobile phones can read the same content.
Reply:
Yes, ah, I am also considering this issue, the program has a good interface to the left, but now I do not have their own website. If they do, then the server is simply thinking about how to engage on how to engage in, ah, which has so tangled ah.
Reply:
I just have encountered this problem is the server's URL right look
Reply:
I am also in the simulator can not be in the real machine. But ip is not replaced.
Reply:
http://113.108.239.107/data/101010100.html
This can be a
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment