JAVA连接SAP时出现的错误(102)|JAVA连接SAP时出现的错误(102) JCO_ERROR_COMMUNICATION(Connect to SAP gateway failed)

JAVA连接SAP时出现的错误(102) JCO_ERROR_COMMUNICATION: Initialization of repository destination ABAP_AS_WITH_POOL failed: Connect to SAP gateway failed 解决办法

com.sap.conn.jco.JCoException: (102) JCO_ERROR_COMMUNICATION: Initialization of repository destination ABAP_AS_WITH_POOLfailed: Connect to SAP gateway failed Connection parameters: TYPE=A DEST=ABAP_AS_WITH_POOL ASHOST=172.20.0.172 SYSNR=51 PCS=1LOCATIONCPIC (TCP/IP) on local host with Unicode ERRORpartner '172.20.0.172:3351' not reached TIMESun Apr 28 18:47:59 2019 RELEASE721 COMPONENTNI (network interface) VERSION40 RC-10 MODULEnixxi.cpp LINE3289 DETAILNiPConnect2: 172.20.0.172:3351 SYSTEM CALL connect ERRNO10060 ERRNO TEXTWSAETIMEDOUT: Connection timed out COUNTER2 at com.sap.conn.jco.rt.RfcDestination.getSystemID(RfcDestination.java:1100) at com.sap.conn.jco.rt.RepositoryManager.getRepository(RepositoryManager.java:29) at com.sap.conn.jco.rt.RfcDestination.initRepository(RfcDestination.java:1049) at com.sap.conn.jco.rt.RfcDestination.getRepository(RfcDestination.java:1193) at com.sap.conn.jco.rt.RfcDestination.getRepository(RfcDestination.java:33) at com.pcmall.MultiFromSAP.main(MultiFromSAP.java:16) Caused by: com.sap.conn.jco.JCoException: (102) JCO_ERROR_COMMUNICATION: Connect to SAP gateway failed Connection parameters: TYPE=A DEST=ABAP_AS_WITH_POOL ASHOST=172.20.0.172 SYSNR=51 PCS=1LOCATIONCPIC (TCP/IP) on local host with Unicode ERRORpartner '172.20.0.172:3351' not reached TIMESun Apr 28 18:47:59 2019 RELEASE721 COMPONENTNI (network interface) VERSION40 RC-10 MODULEnixxi.cpp LINE3289 DETAILNiPConnect2: 172.20.0.172:3351 SYSTEM CALL connect ERRNO10060 ERRNO TEXTWSAETIMEDOUT: Connection timed out COUNTER2 at com.sap.conn.jco.rt.MiddlewareJavaRfc.generateJCoException(MiddlewareJavaRfc.java:625) at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcClient.connect(MiddlewareJavaRfc.java:1384) at com.sap.conn.jco.rt.ClientConnection.connect(ClientConnection.java:704) at com.sap.conn.jco.rt.RepositoryConnection.connect(RepositoryConnection.java:72) at com.sap.conn.jco.rt.PoolingFactory.init(PoolingFactory.java:115) at com.sap.conn.jco.rt.ConnectionManager.createFactory(ConnectionManager.java:349) at com.sap.conn.jco.rt.DefaultConnectionManager.createFactory(DefaultConnectionManager.java:46) at com.sap.conn.jco.rt.ConnectionManager.getFactory(ConnectionManager.java:323) at com.sap.conn.jco.rt.RfcDestination.getSystemID(RfcDestination.java:1094) ... 5 moreCaused by: RfcException: message: Connect to SAP gateway failed Connection parameters: TYPE=A DEST=ABAP_AS_WITH_POOL ASHOST=172.20.0.172 SYSNR=51 PCS=1LOCATIONCPIC (TCP/IP) on local host with Unicode ERRORpartner '172.20.0.172:3351' not reached TIMESun Apr 28 18:47:59 2019 RELEASE721 COMPONENTNI (network interface) VERSION40 RC-10 MODULEnixxi.cpp LINE3289 DETAILNiPConnect2: 172.20.0.172:3351 SYSTEM CALL connect ERRNO10060 ERRNO TEXTWSAETIMEDOUT: Connection timed out COUNTER2return code: RFC_FAILURE (1) error group: 102 key: RFC_ERROR_COMMUNICATION at com.sap.conn.rfc.engine.RfcIoControl.error_end(RfcIoControl.java:259) at com.sap.conn.rfc.engine.RfcIoControl.ab_rfcopen(RfcIoControl.java:101) at com.sap.conn.rfc.api.RfcApi.RfcOpen(RfcApi.java:81) at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcClient.connect(MiddlewareJavaRfc.java:1348) ... 12 more

【JAVA连接SAP时出现的错误(102)|JAVA连接SAP时出现的错误(102) JCO_ERROR_COMMUNICATION(Connect to SAP gateway failed)】遇到以上错误时,你的连接程序中可能缺少了Router字符串
connectProperties.setProperty(DestinationDataProvider.JCO_SAPROUTER,"xxxxxx");

加上这段代码,再试一下应该就可以了,希望可以帮到你。

    推荐阅读