代码之家  ›  专栏  ›  技术社区  ›  Subodh Joshi dileep H

AWS:无法从本地运行的java客户端访问端点?

  •  0
  • Subodh Joshi dileep H  · 技术社区  · 3 年前

    在我们的组织中,我们使用AWS进行应用程序部署。部署到AWS中的应用程序通过https运行。现在,我想从本地笔记本电脑上运行的java桌面应用程序访问一些端点,但它失败了,出现以下错误

    java.net.SocketException: Connection or outbound has closed
            at sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:1172)
            at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
            at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
            at org.apache.commons.httpclient.ChunkedOutputStream.flush(ChunkedOutputStream.java:191)
            at java.util.zip.DeflaterOutputStream.flush(DeflaterOutputStream.java:282)
            at com.ctc.wstx.io.UTF8Writer.flush(UTF8Writer.java:99)
            at com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:214)
            at com.ctc.wstx.sw.BufferingXmlWriter.close(BufferingXmlWriter.java:194)
            at com.ctc.wstx.sw.BaseStreamWriter.finishDocument(BaseStreamWriter.java:1690)
            at com.ctc.wstx.sw.BaseStreamWriter.close(BaseStreamWriter.java:288)
            at org.apache.axiom.om.impl.MTOMXMLStreamWriter.close(MTOMXMLStreamWriter.java:188)
            at org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:197)
            at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:79)
            at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84)
            at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499)
            at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
            at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
            at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
            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:346)
            at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:557)
            at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199)
            at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76)
            at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400)
            at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225)
            at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:438)
            at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
            at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
            at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
            at com.comptel.schemas.wsdl.comptel.catalog.internal.SecurityAPIStub.login(SecurityAPIStub.java:271)
            at com.axiomsystems.activecatalog.designer.data.DataProxy.login(DataProxy.java:229)
            at com.axiomsystems.activecatalog.designer.dialogs.LoginDialog.login(LoginDialog.java:276)
            at com.axiomsystems.activecatalog.designer.dialogs.LoginDialog.okPressed(LoginDialog.java:229)
            at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:472)
            at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
            at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
            at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
            at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
            at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
            at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
            at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
            at org.eclipse.jface.window.Window.open(Window.java:801)
            at com.axiomsystems.activecatalog.designer.actions.LoginAction.run(LoginAction.java:68)
            at com.axiomsystems.activecatalog.designer.ApplicationWorkbenchAdvisor.postStartup(ApplicationWorkbenchAdvisor.java:32)
            at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2322)
            at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
            at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)
            at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
            at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)
            at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
            at com.axiomsystems.activecatalog.designer.Application.start(Application.java:119)
            at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
            at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
            at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
            at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)
            at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
            at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
            at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
    

    在我的本地机器中,我使用的是以下java版本

    openjdk version "1.8.0_292"
    OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
    OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)
    

    我已经在Java密钥库中添加了证书。

    1 回复  |  直到 3 年前
        1
  •  0
  •   Drashti Dobariya    3 年前

    为了允许连接到服务器,您必须为分配给服务器正在运行的AWS EC2实例的安全组指定入站和出站规则。

    要使用HTTPS,需要在入站规则中添加端口443,其中包含要为服务器列入白名单的IP地址(类似于端口80的HTTP)。如果没有静态IP,则可以通过添加0.0.0.0/0将所有IP列入白名单,如下所示:

    Add inbound rule Inbound rules

    您还需要添加带有白名单IP的出站规则(或0.0.0.0/0以允许所有IP)。

    Add outbound rule

    outbound rules

    您可以阅读有关安全组的更多信息 here