|
|
@@ -7,6 +7,7 @@ import com.its.dsrc.global.AppRepository;
|
|
|
import com.its.dsrc.xnettcp.dsrc.codec.DsrcTcpServerEncoder;
|
|
|
import com.its.dsrc.xnettcp.dsrc.handler.DsrcAsn1ServerPacketInboundHandler;
|
|
|
import io.netty.bootstrap.ServerBootstrap;
|
|
|
+import io.netty.buffer.PooledByteBufAllocator;
|
|
|
import io.netty.channel.ChannelFuture;
|
|
|
import io.netty.channel.ChannelOption;
|
|
|
import io.netty.channel.EventLoopGroup;
|
|
|
@@ -66,14 +67,22 @@ public class DsrcTcpCommServerService {
|
|
|
log.info("*********************************************************************************");
|
|
|
|
|
|
try {
|
|
|
- if (this.runningConfig.getCommBindingAddr().equals("0.0.0.0")) {
|
|
|
- this.channelFuture = serverBootstrap.bind(this.runningConfig.getCommBindingPort());
|
|
|
- }
|
|
|
- else {
|
|
|
- this.channelFuture = serverBootstrap.bind(this.runningConfig.getCommBindingAddr(), this.runningConfig.getCommBindingPort());
|
|
|
+// if (this.runningConfig.getCommBindingAddr().equals("0.0.0.0")) {
|
|
|
+// this.channelFuture = serverBootstrap.bind(this.runningConfig.getCommBindingPort()).sync();
|
|
|
+// }
|
|
|
+// else {
|
|
|
+// this.channelFuture = serverBootstrap.bind(this.runningConfig.getCommBindingAddr(), this.runningConfig.getCommBindingPort()).sync();
|
|
|
+// }
|
|
|
+ this.channelFuture = serverBootstrap.bind("0.0.0.0", this.runningConfig.getCommBindingPort()).sync();
|
|
|
+ if (!this.channelFuture.isSuccess()) {
|
|
|
+ log.error("DsrcTcpCommServerService bind failed: {}", channelFuture.cause().getMessage());
|
|
|
}
|
|
|
- }
|
|
|
- catch (Exception e) {
|
|
|
+ } catch (InterruptedException ie) {
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
+ log.error("DsrcTcpCommServerService bind InterruptedException: {}", ie.getMessage());
|
|
|
+ if (this.acceptGroups != null) this.acceptGroups.shutdownGracefully();
|
|
|
+ if (this.workerGroups != null) this.workerGroups.shutdownGracefully();
|
|
|
+ } catch (Exception e) {
|
|
|
log.error("DsrcTcpCommServerService bind exception: {}", e.getMessage());
|
|
|
if (this.acceptGroups != null) this.acceptGroups.shutdownGracefully();
|
|
|
if (this.workerGroups != null) this.workerGroups.shutdownGracefully();
|
|
|
@@ -82,14 +91,21 @@ public class DsrcTcpCommServerService {
|
|
|
|
|
|
public void stop() {
|
|
|
try {
|
|
|
+ if (this.channelFuture != null && this.channelFuture.channel() != null) {
|
|
|
+ this.channelFuture.channel().close().sync();
|
|
|
+ this.channelFuture = null;
|
|
|
+ }
|
|
|
if (this.acceptGroups != null) {
|
|
|
this.acceptGroups.shutdownGracefully().sync();
|
|
|
+ this.acceptGroups = null;
|
|
|
}
|
|
|
if (this.workerGroups != null) {
|
|
|
this.workerGroups.shutdownGracefully().sync();
|
|
|
+ this.workerGroups = null;
|
|
|
}
|
|
|
// if (this.channelFuture != null && this.channelFuture.channel() != null) {
|
|
|
// this.channelFuture.channel().closeFuture().sync();
|
|
|
+// this.channelFuture = null;
|
|
|
// }
|
|
|
}
|
|
|
catch (InterruptedException e) {
|
|
|
@@ -120,6 +136,9 @@ public class DsrcTcpCommServerService {
|
|
|
serverBootstrap.option(ChannelOption.SO_REUSEADDR, true);
|
|
|
serverBootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, this.runningConfig.getCommConnectTimeoutSeconds()*1000);
|
|
|
|
|
|
+ serverBootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
|
|
|
+ serverBootstrap.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
|
|
|
+
|
|
|
serverBootstrap.childOption(ChannelOption.SO_LINGER, 0); // 4way-handshake 비활성
|
|
|
serverBootstrap.childOption(ChannelOption.SO_KEEPALIVE, false); // KEEPALIVE 비활성(활성: true)
|
|
|
serverBootstrap.childOption(ChannelOption.SO_REUSEADDR, true); // 소켓 재사용
|