解决连接被拒的方法是什么:连接 [英] What is a work around for Connection refused: connect

查看:508
本文介绍了解决连接被拒的方法是什么:连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从另一个站点获取信息.当我尝试做

URL url = new URL("theSite");
url.getContent();

它抛出一个Connection refused: connect exception.这是否意味着该站点将不允许自动连接?还有另一种获取此信息的方法吗?

解决方案

这可能意味着几件事:

  • 该站点出现问题并且正在主动断开连接(拒绝与超时不同,拒绝完全没有响应)
  • 中间人可能拒绝了您的联系,例如防火墙,尽管如果您可以通过浏览器访问该站点,则不太可能
  • 您使用的端口错误,即您输入https://时的意思是http://,反之亦然?
  • 您的浏览器正在通过代理访问网站.检查浏览器的代理设置,并在url.openConnection(Proxy)
  • 中使用它们

telnet是您的朋友,当您执行以下操作

telnet thesite 80 [或您需要的任何端口] GET/URL HTTP/1.0 主持人:网站

I am trying to pull information from another site. When I try and do

URL url = new URL("theSite");
url.getContent();

It throws a Connection refused: connect exception. Does this mean the site will not allow automated connections? Is there another way to get this information?

解决方案

It can mean several things:

  • The site is having problems and is actively dropping connections (Refused is different from timed out, where no response was received at all)
  • An intermediary may have refused your connection, e.g. a Firewall, although if you can access the site via a browser then this is not likely the case
  • You are using the wrong port, i.e. did you mean http:// when you typed https:// or vice versa?
  • Your browser is accessing the site via a proxy. Check the browsers proxy settings and use them in url.openConnection(Proxy)

telnet is your friend, what happens when you:

telnet thesite 80 [or whatever port you require] GET /URL HTTP/1.0 Host: thesite

这篇关于解决连接被拒的方法是什么:连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆