Skip to content

Commit 71f442d

Browse files
jingyustiartsly
authored andcommitted
Fixed send disconnect request twice error
1 parent 73970ab commit 71f442d

3 files changed

Lines changed: 20 additions & 11 deletions

File tree

services/active-proxy/src/main/java/elastos/carrier/service/activeproxy/ActiveProxy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
public class ActiveProxy implements CarrierService {
3535
static final String NAME = "ActiveProxy";
36-
static final int DEFAULT_PORT = 10088;
36+
static final int DEFAULT_PORT = 8090;
3737
static final String DEFAULT_PORT_MAPPING_RANGE = "32768-65535";
3838

3939
@SuppressWarnings("unused")

services/active-proxy/src/main/java/elastos/carrier/service/activeproxy/ProxyConnection.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ private void handlePacket(Buffer packet) {
363363
handleAttach(packet);
364364
return;
365365
} else {
366-
log.error("Connection {} got wrong packet, AUTH or ATTACH excepted", getName());
366+
log.error("Connection {} got wrong packet {}, AUTH or ATTACH excepted",
367+
getName(), PacketFlag.toString(flag));
367368
close();
368369
}
369370
break;
@@ -373,7 +374,8 @@ private void handlePacket(Buffer packet) {
373374
handleKeepAlive(packet);
374375
return;
375376
} else {
376-
log.error("Connection {} got wrong packet, PING excepted", getName());
377+
log.error("Connection {} got wrong packet {}, PING excepted",
378+
getName(), PacketFlag.toString(flag));
377379
close();
378380
}
379381
break;
@@ -383,7 +385,8 @@ private void handlePacket(Buffer packet) {
383385
handleConnectAck(packet);
384386
return;
385387
} else {
386-
log.error("Connection {} got wrong packet, CONNECT ACK excepted", getName());
388+
log.error("Connection {} got wrong packet {}, CONNECT ACK excepted",
389+
getName(), PacketFlag.toString(flag));
387390
close();
388391
}
389392
break;
@@ -396,7 +399,8 @@ private void handlePacket(Buffer packet) {
396399
handleDisconnect(packet);
397400
return;
398401
} else {
399-
log.error("Connection {} got wrong packet, DATA or DISCONNECT excepted", getName());
402+
log.error("Connection {} got wrong packet {}, DATA or DISCONNECT excepted",
403+
getName(), PacketFlag.toString(flag));
400404
close();
401405
}
402406
break;
@@ -546,8 +550,13 @@ public void connectClient(NetSocket clientSocket) {
546550

547551
clientSocket.closeHandler(clientClose);
548552
clientSocket.exceptionHandler(t -> {
549-
log.error("Client socket error", t);
550-
clientClose.handle(null);
553+
if (log.isDebugEnabled())
554+
log.error("Client socket error", t);
555+
else
556+
log.error("Client socket error: {}", t.getMessage());
557+
558+
clientSocket.close();
559+
this.clientSocket = null;
551560
});
552561
clientSocket.handler(this::handleClientData);
553562

@@ -558,10 +567,10 @@ public void connectClient(NetSocket clientSocket) {
558567
}
559568

560569
private void disconnectClient() {
561-
if (this.clientSocket != null) {
570+
if (clientSocket != null) {
562571
needSendDisconnect = false;
563-
this.clientSocket.close();
564-
this.clientSocket = null;
572+
clientSocket.close();
573+
clientSocket = null;
565574
}
566575
}
567576

services/dht-proxy/src/main/java/elastos/carrier/service/dhtproxy/DHTProxy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
public class DHTProxy implements CarrierService {
3535
private static final String NAME = "DHT Proxy";
36-
private static final int DEFAULT_PORT = 10080;
36+
private static final int DEFAULT_PORT = 8088;
3737

3838
private ServiceContext context;
3939
private ProxyServer server;

0 commit comments

Comments
 (0)