Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.github.tobato.fastdfs.domain.conn.DefaultConnection - close connection error #279

Open
arui3015 opened this issue Jul 19, 2022 · 1 comment

Comments

@arui3015
Copy link

在定时关闭连接,或者在借出连接时,如果发现连接已经关闭,再去调用close方法,必然会出发这个错误,能否在连接关闭时做个判断,如果连接关闭时,就不调用 this.socket.getOutputStream().write(header);这一步了,避免打出一个标题错误日志。

public synchronized void close() {
LOGGER.debug("disconnect from {}", this.socket);
byte[] header = new byte[10];
Arrays.fill(header, (byte)0);
byte[] hex_len = BytesUtil.long2buff(0L);
System.arraycopy(hex_len, 0, header, 0, hex_len.length);
header[8] = 82;
header[9] = 0;

    try {
        this.socket.getOutputStream().write(header);
        this.socket.close();
    } catch (IOException var7) {
        LOGGER.error("close connection error", var7);
    } finally {
        IOUtils.closeQuietly(this.socket);
    }

}
@arui3015
Copy link
Author

研究了有一下,貌似是服务器主动断开了连接,FastDFS_Client没有收到断开事件,导致借出的连接时断开的,断开时又去this.socket.getOutputStream().write(header);导致报错,大佬研究过吗?服务器断开之前是不是也有事件推送的啊?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant