通过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时获取页面,它运行正常并且能够正确获取数据。
我做错了什么?在发出请求时是否需要指定传出端口?
答案 0 :(得分:1)
对我来说,版本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