2013-01-31 70 views
14

क्या का कारण हो सकता है हो सकता है:अपाचे CXF संदेश नहीं भेज और समय पढ़ा

org.apache.cxf.interceptor.Fault: Could not send Message.

Caused by: java.net.SocketTimeoutException: SocketTimeoutException invoking https://xxx.xxx.xxx.xxx:8443/services/test: Read timed out

यह आमतौर पर के बाद मैं ws करने के लिए एक साबुन अनुरोध भेजने होता है। मैं apache cxf का उपयोग कर रहा हूँ। मुझे पूरा यकीन है कि ws ऊपर और चल रहा है क्योंकि समय समाप्त होने से पहले ग्राहक 2 और अनुरोध भेजेगा। तीसरा साबुन अनुरोध में टाइमआउट होता है।

उत्तर

10

त्रुटि संदेश का अर्थ है कि आपका वेब सेवा क्लाइंट नेटवर्क पर दूरस्थ वेब सेवा से डेटा प्राप्त करने का प्रयास कर रहा था, लेकिन किसी विशिष्ट अवधि के लिए कोई डेटा प्राप्त नहीं हुआ था, इसलिए वेब सेवा क्लाइंट ने डेटा की प्रतीक्षा करना बंद कर दिया प्राप्त किया जाना चाहिए।

संभावित कारणों में से एक यह हो सकता है कि timeout संपत्ति बहुत कम है। 30000 और 60000 एमएस के क्रमशः सीएक्सएफ डिफ़ॉल्ट मानों के लिए डिफ़ॉल्ट। इन्हें बदला जा सकता है कि आप अपना ग्राहक कैसे बना रहे हैं।

आप जावा कोड का उपयोग कर एक ग्राहक बना रहे हैं आप का उपयोग कर सकते हैं:

//1 minute for connection 
((BindingProvider) wsPort).getRequestContext().put("com.sun.xml.ws.connect.timeout", 1 * 60 * 1000); 

//3 minutes for request 
((BindingProvider) wsPort).getRequestContext().put("com.sun.xml.ws.request.timeout", 3 * 60 * 1000); 

आप वसंत का उपयोग कर रहे हैं, तो आप इस तरह की एक मानचित्र का उपयोग कर सकते हैं:

<util:map id="jaxwsProperties"> 
    <entry key="com.sun.xml.internal.ws.request.timeout"> 
     <value type="java.lang.Integer">120000</value> 
    </entry> 
    <entry key="com.sun.xml.internal.ws.connect.timeout"> 
     <value type="java.lang.Integer">60000</value> 
    </entry> 
</util:map> 

तो में है कि नक्शे सेट आपकी <jaxws:client.../> कॉन्फ़िगरेशन।

+0

ठीक बीमार है कि कोशिश :) वैसे भी गलत साबुन अनुरोध प्रारूप भी त्रुटि के अपराधी ?? ,, मैं गलती से एक साबुन अनुरोध अशक्त के साथ भेजा जा सकता है कर सकते हैं मूल्य/"" मानों को अचानक मुझे डब्ल्यूएस साबुन प्रतिक्रिया मिली .. – irumi

+2

गुणों ने क्रमशः नाम बदलकर 'javax.xml.ws.client.connectionTimeout' और 'javax.xml.ws.client.receiveTimeout' कर दिया है। –

14

मुझे अपने webservice क्लाइंट के लिए भी इस त्रुटि का सामना करना पड़ा है। मेरे लिए काम किया गया समाधान http क्लाइंट को CXF कॉन्फ़िगरेशन फ़ाइल (cxf.xml) में कॉन्फ़िगर करना है।

Apache CXF document में दस्तावेज के रूप में:

1.Add http-नाली नाम स्थान और XSD:

<beans ... 
     xmlns:http-conf="http://cxf.apache.org/transports/http/configuration 
     ... 
     xsi:schemaLocation="... 
      http://cxf.apache.org/transports/http/configuration 
      http://cxf.apache.org/schemas/configuration/http-conf.xsd 
     ..."> 

2.Add http-नाली टैग/तत्व और सेट RecieveTimeout/कनेक्शन टाइमआउट 180000ms:

<http-conf:conduit name="*.http-conduit"> 
     <http-conf:client 
         ConnectionTimeout="300000" 
         ReceiveTimeout="300000"/>  
</http-conf:conduit> 
0

आप अपाचे सीएक्सएफ स्रोत से प्राप्त टाइमआउट सेटिंग बदलना चाहते हैं और अपने सर्वर में मौजूदा सीएक्सएफ-आरटी-ट्रांसपोर्ट-http-version.jar को प्रतिस्थापित कर सकते हैं।

संक्षिप्त निर्देश: (Wildfly 8.2/undertow read time out से निर्देश मिल गया) पथ के लिए Maven

  • जोड़ें/बिन अपाचे से

    1. डाउनलोड CXF2.7.16 src
    2. निर्यात MAVEN_OPTS = त्रुटियों
    3. permgen ठीक करने के लिए -Xmx512m
    4. ओपन ./rt/transports/http/src/main/resources/schemas/wsdl/http-conf.xsd और 60000 से ReceiveTimeout को जो भी आवश्यक हो, को बदलें। 600000 (10 मिनट)
    5. रन mvn -Pfastinstall
    6. "पैच" सीएक्सएफ-आरटी-ट्रांसपोर्ट-http-2.7 प्राप्त करें।16.jar से ./rt/transports/http/target फ़ोल्डर
    7. अपने सर्वर में cxf-rt-transports-http-2.7.16.jar को बदलें। उदाहरण के लिए, wildfly8.2 के साथ, यह .//modules/system/layers/base/org/apache/cxf/impl/main फ़ोल्डर में है और इस पैच किए गए cxf-rt का उपयोग करने के लिए उसी फ़ोल्डर के अंदर module.xml को अद्यतन करना याद रखें -transports-http-2.7.16.jar।

    यह सर्वर में उपयोग किए गए अंतर्निहित अपाचे सीएक्सएफ के कारण सॉकेटटाइमआउट अपवाद को हल करना चाहिए।

  • 2

    एक और approche समय समाप्ति विन्यास के लिए (प्रोग्राम के रूप में):

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); 
    Object serviceClass = factory.create(); 
    defineTimeouts(serviceClass); 
    
    static void defineTimeouts(Object serviceClass) { 
        Client cxfClient = ClientProxy.getClient(serviceClass); 
        HTTPConduit httpConduit = (HTTPConduit) cxfClient.getConduit(); 
    
        HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); 
        httpClientPolicy.setConnectionTimeout(DEFAULT_CLIENT_CONNECTION_TIMEOUT); 
        httpClientPolicy.setReceiveTimeout(DEFAULT_CLIENT_RECEIVE_TIMEOUT); 
        httpConduit.setClient(httpClientPolicy); 
    }