Reputation: 408
In Kotlin/Java, When I try to send a bytearray message to a TCP server and receive the message, I am getting the exception
org.springframework.messaging.MessagingException: Exception while awaiting reply; nested exception is java.io.IOException: Socket closed during message assembly
at org.springframework.integration.support.utils.IntegrationUtils.wrapInHandlingExceptionIfNecessary(IntegrationUtils.java:189)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:179)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:115)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:132)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:105)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:73)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:453)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:401)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187)
at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:233)
at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:47)
at org.springframework.messaging.core.AbstractMessagingTemplate.sendAndReceive(AbstractMessagingTemplate.java:46)
Below is my TCP configuration class
@Configuration
class TcpIntegrationConfiguration(
private val tcpConfigurationProperties: TcpConfigurationProperties
) {
@Bean
fun tcpClient(): IntegrationFlow {
return IntegrationFlows.from(Gateway::class.java)
.handle(
Tcp.outboundGateway(
Tcp.netClient(
tcpConfigurationProperties.host, tcpConfigurationProperties.port)
.soTimeout(tcpConfigurationProperties.timeout)))
.get()
}
}
Any answers/suggestions?
Upvotes: 2
Views: 1946
Reputation: 174494
You need to show the full stack trace (cause etc) as well as the server-side code.
But Socket closed during message assembly
seems quite clear.
The server closed the socket without sending a complete reply; the default deserializer expects to see \r\n
to signify the end of the message.
Upvotes: 4