File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
dinky-admin/src/main/java/org/dinky/ws Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,9 @@ public enum EventType {
9494 private static final Map <Session , RequestDTO > TOPICS = new ConcurrentHashMap <>();
9595
9696 @ OnOpen
97- public void onOpen (Session session ) {}
97+ public void onOpen (Session session ) {
98+ session .setMaxIdleTimeout (30000 );
99+ }
98100
99101 @ OnClose
100102 public void onClose (Session session ) {
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ export default () => {
5959 const ws = useRef < WebSocket > ( ) ;
6060
6161 const reconnect = ( ) => {
62- if ( ws . current && ws . current . readyState === WebSocket . CLOSED ) {
62+ if ( ws . current && ws . current . readyState === WebSocket . OPEN ) {
6363 ws . current . close ( ) ;
6464 }
6565 ws . current = new WebSocket ( wsUrl ) ;
@@ -119,9 +119,9 @@ export default () => {
119119 reconnect ( ) ;
120120 } else {
121121 const currentTime = new Date ( ) . getTime ( ) ;
122- if ( currentTime - lastPongTimeRef . current > 15000 ) {
122+ if ( currentTime - lastPongTimeRef . current > 15 ) {
123123 reconnect ( ) ;
124- } else if ( currentTime - lastPongTimeRef . current > 5000 ) {
124+ } else if ( currentTime - lastPongTimeRef . current > 5 ) {
125125 const token = JSON . parse ( localStorage . getItem ( TOKEN_KEY ) ?? '{}' ) ?. tokenValue ;
126126 ws . current . send ( JSON . stringify ( { token, type : 'PING' } ) ) ;
127127 }
You can’t perform that action at this time.
0 commit comments