처음부터 차근차근

jsp : No operations allowed after connection closed. 본문

Error&Warning

jsp : No operations allowed after connection closed.

_soyoung 2022. 8. 7. 00:01
반응형

No operations allowed after connection closed.

(연결이 닫힌 후에는 작업이 허용되지 않습니다.)

 

mysql에서 8시간 이상 사용이 없으면 자동으로 연결을 해제하는데, 

연결이 해제 된 이후에 sql문을 실행해서 생기는 오류이다.

 

Connection reset by peer: socket write error    <-   connection close 에러가 났을 때 항상 같이 났던 오류

write 시 상대방 socket close 된 경우에 나는 에러. connection이 close되서 나는 오류인 것 같다.

 

 

 

해결 방법은 두 가지다.

1. autoReconnect=true 사용

2. 서버 wait_timeout 수정

 

두 번째 방법은

MySQL console 에서 Set GLOBAL wait_timeout = 숫자; 로 설정하거나, /etc/my.cnf 파일을 수정하면 된다.

하지만 wait_timeout은 커넥션 수를 증가가 됨으로 좋은 방법이 아니기 때문에 첫 번째 방법을 사용했다.

 

첫 번째 방법

jdbc:mysql://호스트:포트/DB명?autoReconnect=true

이런식으로 뒤에 autoReconnect=true를 추가하면 된다.

 

이렇게 하면 mysql 연결이 끊겼을 때 자동으로 reconnect되어 위의 에러를 해결할 수 있다.

 

 

 

 

+ 로그를 자세히 보니 해결방법이 로그에 나와있었다...

The last packet successfully received from the server was 980,371 milliseconds ago. 

The last packet sent successfully to the server was 980,377 milliseconds ago. 

(서버에서 성공적으로 수신된 마지막 패킷은 980,371밀리초 전입니다.)

(서버에 성공적으로 전송된 마지막 패킷은 980,377밀리초 전입니다.)

 

is longer than the server configured value of 'wait_timeout'. 

('wait_timeout'의 서버 구성 값보다 깁니다.)

 

You should consider either expiring and/or testing connection validity before use in your application, 

increasing the server configured values for client timeouts

or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

(클라이언트 timeout에 대해 서버 구성 값을 늘리거나,

Connector/J 연결 속성 'autoReconnect=true'를 사용하는 것을 고려해야 합니다.)

 

다음엔 로그를 꼭 확인해야겠다

 

 

반응형
Comments