Results 1 to 7 of 7

Thread: Socket closed when sending through tcp-outbound-gateway

Hybrid View

  1. #1
    Join Date
    Apr 2012
    Posts
    4

    Default Socket closed when sending through tcp-outbound-gateway

    Hello. I was wondering if any of you can please help me with this problem.
    I am trying to use a tcp-outbound-gateway to communicate with a TCP server using a specified format.
    I'm currently trying to do an integration test on this client using the tcp-inbound-gateway as a stand-in for the actual tcp server (because an instance of the actual server is not available to us at the moment).

    The problem is... I'm getting a "socket is closed" exception on my test case. What am I missing here?

    Below are the configuration files for the test case:

    server configuration
    Code:
     
    	<int:channel id="bytesToStringChannel"/>
    	<int:channel id="silverlakeChannel"/>
    	<int:channel id="errorChannel"/>
    
    	<int-ip:tcp-connection-factory id="silverlakeConnectionFactory"
    		type="server" pool-size="5" port="8787"/>
    	
    	<int-ip:tcp-inbound-gateway id="silverlakeGateway"
    		connection-factory="silverlakeConnectionFactory"
    		request-channel="bytesToStringChannel"
    		reply-channel="silverlakeChannel"
    		error-channel="errorChannel"/>
    	
    	<int:transformer id="serverBytes2String"
    		input-channel="bytesToStringChannel"
    		output-channel="silverlakeChannel"
    		expression="new String(payload,${casa.message.encoding})"/>
    	
    	<int:service-activator input-channel="silverlakeChannel"
    		ref="silverlakeService"
    		method="process"/>
    	
    	<bean id="silverlakeService" class="com.ucpb.tfs.silverlake.SilverlakeService"/>
    client configuration
    Code:
    	<int-ip:tcp-connection-factory id="casaConnectionFactory"
    		host="localhost" port="8787" type="client"
    		single-use="true" pool-size="5" so-timeout="10000"
    		serializer="casaSerializer" deserializer="casaSerializer" />
    	
    	<int-ip:tcp-outbound-gateway
    		connection-factory="casaConnectionFactory"
    		request-channel="casaRequestChannel" reply-channel="casaResponseChannel"
    		request-timeout="10000"
    		reply-timeout="10000"/>

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,040

    Default

    Can you provide a debug log from both sides (or just the test, if the test launches both contexts).
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Apr 2012
    Posts
    4

    Default Log file

    Hello again.
    Attached is the log file of the test case.
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,040

    Default

    This is the "smoking gun"

    Code:
    Read exception localhost:8787:18f7dc53-d5cd-4fdc-918b-6e4586b1ee37 NullPointerException:null:null
    My best guess is a nullpointer exception in your ...

    Code:
    deserializer="casaSerializer"
    ... but it could be our code. If you run with TRACE debug, you'll get a full stack trace for the NPE.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  5. #5
    Join Date
    Apr 2012
    Posts
    4

    Default Logs

    My apologies. I forgot to wire a class in the serializer.
    I'm still getting a message timeout exception though. After the sending the message through the gateway, the connection just hangs.
    Attached Files Attached Files

  6. #6
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,040

    Default

    It's hard for me to see what's going on because I don't know what your serializer is sending, but it is suspicious that you have a custom serializer on the client side, but you are using the standard ByteArrayCrLfSerializer on the server side.

    Looks to me like the data your serializer is sending is not terminated by CRLF.

    Your server needs to understand when it has received a complete message in your...

    ...specified format.
    Only when we know we have a complete message can we forward it onto the bytesToStringChannel.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  7. #7
    Join Date
    Apr 2012
    Posts
    4

    Default

    Ugh. Of course.... It was just as you said. I failed to implement the serializer/deserializer pair on the server side.
    Tests are now working perfectly. Thanks for the big help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •