nginx tcp代理后服务端能收到客户端消息,也能正常发小心,但客户端收不到服务端返回的消息

最近在用Java NIO做迁移文件,本地测试是可以的,但是本地连接测试环境,并使用Nginx转发时(本地连本地,用Nginx转发也不行),出现服务端能收能发,但是客户端收到的是null(如果是对象字符串,所有的属性都是null),调试了好久不知道怎么弄,请大神们帮我

Nginx配置如下:
stream {

#-------------transferfile------------------------
upstream transferfile {
    hash $remote_addr consistent;
    server 192.168.1.91:1234  max_fails=3 fail_timeout=30s;
}

server {
    listen 8091;
    proxy_connect_timeout 30s;
    proxy_timeout 600s;
    proxy_pass transferfile;
}

}

服务端发送信息:
private void responseData(SocketChannel socketChannel, String response) {
ByteBuffer buffer = ByteBuffer.wrap(response.getBytes());
try {
socketChannel.write(buffer);
buffer.clear();
socketChannel.close();
} catch (IOException e) {
e.printStackTrace();
}
}

客户端接收信息
public String receiveData(SocketChannel socketChannel) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
String response = "";
try {
ByteBuffer buffer = ByteBuffer.allocate(1024);
byte[] bytes;
int count = 0;
while ((count = socketChannel.read(buffer)) >= 0) {
buffer.flip();
bytes = new byte[count];
buffer.get(bytes);
baos.write(bytes);
buffer.clear();
}

        bytes = baos.toByteArray();
        response = new String(bytes, "UTF-8");
    } finally {
        try {
            baos.close();
        } catch (Exception ex) {
        }

        if(socketChannel != null){
            socketChannel.close();
        }
    }


    return response;
}

https://blog.csdn.net/yejin191258966/article/details/17468081/

问题解决了吗 我也遇到一样的问题了……

好的 我试试