Announcement Announcement Module
Collapse
No announcement yet.
Socket closed when sending through tcp-outbound-gateway Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Can you provide a debug log from both sides (or just the test, if the test launches both contexts).

    Comment


    • #3
      Log file

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

      Comment


      • #4
        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.

        Comment


        • #5
          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.

          Comment


          • #6
            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.

            Comment


            • #7
              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!

              Comment

              Working...
              X