java.lang.IllegalStateException: Already connected
时间: 2023-10-19 19:55:50 浏览: 261
引用\[1\]:在调试程序bug的过程中,出现了java.lang.IllegalStateException: Already connected的异常。这个异常的主要原因有两种。一种是将connection.setInput()放在了connection.connect()的后面,另一种是在get请求中设置了connection.DoOutput()。\[1\]引用\[3\]:在查看了一些RequestProperties相关的方法后,发现在判断connected是否为true的时候,会导致java.lang.IllegalStateException: Already connected异常的出现。\[3\]
这个异常的解决方法有几种。首先,确保在调用connection.connect()之前设置connection.setInput()。其次,如果是在get请求中,不要设置connection.DoOutput()。最后,可以尝试关闭防火墙,因为有时候防火墙的设置可能会导致这个异常的出现。在Linux下关闭防火墙的命令是service iptables stop。\[2\]
#### 引用[.reference_title]
- *1* [java.lang.IllegalStateException: Already connected](https://blog.csdn.net/bell10027/article/details/50417161)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [java.lang.IllegalStateException: Failed to register dubbo://139.224.33.130:20881](https://blog.csdn.net/nxg0916/article/details/123129968)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [【BUG】IllegalStateException:Already connect](https://blog.csdn.net/guafengzhetian_Tu/article/details/119795388)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文