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

[ISSUE #4855] Fix close tcp client failed #4856

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
@Slf4j
public abstract class TcpClient implements Closeable {

protected static transient int CLIENTNO = 0;
protected static int CLIENTNO = 0;

static {
try {
Expand Down Expand Up @@ -123,12 +123,15 @@ public void initChannel(SocketChannel ch) {
@Override
public void close() {
try {

goodbye();

channel.disconnect().sync();
workers.shutdownGracefully();
workers.shutdownGracefully().sync();
if (heartTask != null) {
heartTask.cancel(false);
}
goodbye();

} catch (Exception e) {
Thread.currentThread().interrupt();
log.warn("close tcp client failed.|remote address={}", channel.remoteAddress(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public void registerBusiHandler(ReceiveMsgHook<CloudEvent> handler) throws Event
@Override
public void close() {
try {
goodbye();
super.close();
} catch (Exception ex) {
log.error("exception occurred when close", ex);
Expand Down
Loading