My java program is hitting "http://url:port" kind of url to fetch some data. On my local windows machine deployed on tomcat 6, it is working fine. But on production which is a linux machine having tomcat 6 on it, it gives me connection timeout.
Ironically, if I hit the URL without port number, it will successfully bring me the output but not with port. Not finding any clue, please help.
The snippet of code I am using to connect and fetch data is:
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("59.162.167.36:80/api/…");
httpget.setHeader("User-A开发者_开发技巧gent", "UserAgent: Mozilla/5.0");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
One obvious possibility is that a firewall in front of your production machine is blocking access to that port. Check the firewall.
The answer is straightforward: On production you don't have that port opened, contact the administrator, or the hosting and issue your problem. Of course they will confirm my thesis.
Almost certainly your hosting provider implements a firewall of some description in the data center. This is common practice. Send them a message asking if port X is blocked, and if so can they open it.
精彩评论