在Kotlin / Java中,当我尝试将字节数组消息发送到TCP服务器并收到消息时,我遇到了异常
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)
下面是我的TCP配置类
@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()
}
}
有答案/建议吗?
答案 0 :(得分:0)
您需要显示完整的堆栈跟踪(原因等)以及服务器端代码。
但是Socket closed during message assembly
似乎很清楚。
服务器在没有发送完整答复的情况下关闭了套接字;默认的反序列化程序希望看到\r\n
来表示消息的结尾。