java.net.SocketException: Permission denied: connect
程序员文章站
2022-05-14 21:18:10
...
在window10,执行多线程调用接口发送数据时报错
java.net.SocketException: Permission denied: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:83)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
at sun.net.www.http.HttpClient.New(HttpClient.java:308)
at sun.net.www.http.HttpClient.New(HttpClient.java:326)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:997)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:933)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:851)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1092)
at cn.richinfo.common.utils.HttpRequest.GetResponseString(HttpRequest.java:231)
at cn.richinfo.spring.handler.RequestHandler.postRequest(RequestHandler.java:41)
at cn.richinfo.spring.service.SendFlowPresentService.sendRequest(SendFlowPresentService.java:41)
at cn.richinfo.spring.service.SendFlowPresentService.edit(SendFlowPresentService.java:67)
at cn.richinfo.spring.service.SendFlowPresentService$$FastClassBySpringCGLIB$$b5535fe9.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
at cn.richinfo.spring.service.SendFlowPresentService$$EnhancerBySpringCGLIB$$7fbe26db.edit(<generated>)
at cn.richinfo.spring.handler.SendFlowPresentHandler.run(SendFlowPresentHandler.java:38)
Google后发现原来是java7在一个bug。在Linux系统下执行不会出现该问题(防火墙关闭)!
Cause
- This is a known bug in Java 7, as per this post.
- This can be caused by anti-virus or firewall software blocking Java from connecting to the Server port.
Resolution
- Add
-Djava.net.preferIPv4Stack=true
to theFISHEYE_OPTS
environment variable to help enable support for IPv4 on Java 7. - Change the anti-virus or firewall software so that Java can connect to the server on the specified port.
推荐阅读
-
Serv-U 550 Permission denied 的解决办法
-
Apache启动错误Permission denied: httpd: could not open error log file解决方法
-
日志文件写入失败(permission denied)
-
CentOS7 SSH 密码正确,但仍提示“Permission denied”
-
yum 安装memcache permission denied(拒绝访问) 问题
-
Nginx应对Permission denied和File not found的配置
-
linux下VSFTP 530 Permission denied错误的解决办法
-
Nginx报403 forbidden错误 (13: Permission denied)的解决办法
-
Nginx中报错:Permission denied与Connection refused的解决
-
git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.