【问题标题】:Mule ESB HTTPS INBOUND ENDPOINT CONNECTION FAILUREMule ESB HTTPS 入站端点连接失败
【发布时间】:2015-03-06 07:19:36
【问题描述】:

我目前正在使用 Mule Studio CE 1.3.2 作为开发环境的一部分。我试图设置一个用于测试目的的基本流程,其中包含一个 HTTPS 入站端点,目的是从运行基于 JSSE 的客户端的远程计算机向其发布一些数据。使用的流的实际位直接如下所示:

`<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd 
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
    <https:connector name="HTTP_HTTPS" cookieSpec="netscape" validateConnections="true" sendBufferSize="0" receiveBufferSize="0" receiveBacklog="0" clientSoTimeout="10000" serverSoTimeout="10000" socketSoLinger="0" doc:name="HTTP\HTTPS">
        <https:tls-key-store path="Mule.jks" keyPassword="abc" storePassword="cdfg"/>
        <https:tls-server path="Mule.jks" storePassword="cdfg"/>
        <https:tls-protocol-handler property="com.sun.net.ssl.internal.www.protocol"/>
    </https:connector>
    <flow name="HttpsServerTestFlow1" doc:name="HttpsServerTestFlow1" processingStrategy="asynchronous">
        <https:inbound-endpoint exchange-pattern="one-way" host="192.168.178.4" port="8080" path="test" mimeType="text/plain" connector-ref="HTTP_HTTPS" contentType="application/x-www-form-urlencoded" doc:name="HTTP"/>
        <scripting:component doc:name="Python">
            <scripting:script engine="jython">
                <scripting:text><![CDATA[print "Mule message:"
print message
]]></scripting:text>
            </scripting:script>
        </scripting:component>
    </flow>
</mule>` 

现在,当尝试从其代码(使用已弃用的包允许,但它仅作为快速测试)的 java 客户端连接时:

`import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.Security;
import com.sun.net.ssl.HostnameVerifier;
import com.sun.net.ssl.HttpsURLConnection;


public class HTTPSClient {

    private HttpsURLConnection urlConnection=null;

    private static String host_address="192.168.178.47";

    private static int ssl_port=8080;

    public static void setHost_address(String host_address) {
        HTTPSClient.host_address = host_address;
    }

    public static String getHost_address() {
        return host_address;
    }

    public static void setSsl_port(int ssl_port) {
        HTTPSClient.ssl_port = ssl_port;
    }

    public static int getSsl_port() {
        return ssl_port;
    }

    static{

        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

        System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");

        System.setProperty("javax.net.ssl.keyStore", "C:/Users/vangelis/client.jks");

        System.setProperty("javax.net.ssl.keyStorePassword", "xxxx");

        System.setProperty("javax.net.ssl.trustStore", "C:/Users/vangelis/trust-client.jks");

        System.setProperty("javax.net.ssl.trustStorePassword", "xxxxc");

        System.setProperty("https.protocols", "SSLv3");
    }


    public void sendData(String content){

        try {

            HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier(){

                @Override
                public boolean verify(String hostname, String session) {
                    // TODO Auto-generated method stub
                    return (true);
                }
            });

            URL url=new URL("https://"+getHost_address()+":"+getSsl_port()+"/test");

            urlConnection=(HttpsURLConnection)url.openConnection();

            urlConnection.setRequestMethod("POST");

            urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0");

            urlConnection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");

            urlConnection.setDoOutput(true);

            urlConnection.connect();

            OutputStream out_stream = urlConnection.getOutputStream();

            DataOutputStream out_stream_writer=new DataOutputStream(out_stream);

            out_stream_writer.writeBytes(content);

            out_stream_writer.close();

        }

        catch (MalformedURLException e) {

            e.printStackTrace();
        }

        catch (java.net.SocketException e){

            e.printStackTrace();
        }

        catch (IOException e) {

            e.printStackTrace();
        }
    }


    public static void main(String[] args) {

        String data="data%3Dhello";

        HTTPSClient secure_client= new HTTPSClient();

        secure_client.sendData(data);

        System.out.print("Done...");

    }

}`

我总是在 mule 端收到以下堆栈跟踪:

    **`ERROR 2015-03-05 14:56:09,525 [[httpsservertest].HTTP_HTTPS.receiver.02] org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in Exception Strategy: Connection reset
java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:168)
    at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
    at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:798)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:755)
    at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
    at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:50)
    at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
    at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
    at org.mule.transport.http.HttpServerConnection.readLine(HttpServerConnection.java:219)
    at org.mule.transport.http.HttpServerConnection.readRequest(HttpServerConnection.java:185)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:155)
    at org.mule.work.WorkerContext.run(WorkerContext.java:311)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)`**

请记住,如果我使用带有 https-outbound 端点的第二个 mule 流,以便通过上面讨论的入站端点连接到流,那么一切正常,没有任何错误。看来问题出在java客户端代码上。有人可以帮我一下吗,因为从一个快速而肮脏的集成测试用例开始,我需要很长时间才能解决。 谢谢 万吉利斯

【问题讨论】:

    标签: jakarta-ee mule


    【解决方案1】:

    您自己开发的 HTTP 客户端没有读取 Mule 的 HTTP 响应,因此 Mule 抱怨客户端过早关闭连接。

    要么修复您的客户端以读取来自 Mule 的响应,要么使用适当的 HTTP 客户端(例如 Apache's HTTP Client)。

    【讨论】:

    • 谢谢大卫,你一如既往的正确,不幸的是,在我上传问题后,我自己也注意到了问题的根源,在测试过程中的某个地方,我设法砍掉了代码并错过了Http 响应。无论如何,非常感谢您的宝贵时间。
    猜你喜欢
    • 2012-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-16
    • 1970-01-01
    • 1970-01-01
    • 2018-08-01
    • 1970-01-01
    相关资源
    最近更新 更多