gpt4 book ai didi

java - 出站请求的 BindException

转载 作者:行者123 更新时间:2023-12-01 12:33:31 27 4
gpt4 key购买 nike

通过 java 发出出站请求时(使用 apache.commons.httpclient ),我得到 Permission denied 。以下是 jboss 日志中的根本原因:

Caused by: java.net.BindException: Permission denied
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:353)
at java.net.Socket.bind(Socket.java:598)
at sun.security.ssl.BaseSSLSocketImpl.bind(BaseSSLSocketImpl.java:114)
at sun.security.ssl.SSLSocketImpl.bind(SSLSocketImpl.java:64)
at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:430)
at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:142)
at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:82)
at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:127)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at com.killer923.dataFetcher.net.http.HttpRequestDispatcher.sendGETRequest(HttpRequestDispatcher.java:44)

我尝试使用curl用于通过 ssh 连接到 gear 时获取页面,并且工作正常并且能够正确获取数据。

我做错了什么?发出请求时是否需要指定传出端口?

最佳答案

解决该问题的最简单方法是将 apache commons httpclient 升级到版本 4+。

对我来说,4.3.5 版本有效。这是 Maven 条目:

<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>

获取数据时还需要进行一些更改。

另一种更复杂的方式,旨在覆盖客户端内使用的套接字连接工厂。我没有尝试这种方式,但希望此链接有帮助: https://www.openshift.com/forums/openshift/commons-httpclient-permission-denied

关于java - 出站请求的 BindException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25751716/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com