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

Address idle timeouts on long processes #1177

Merged
merged 1 commit into from
Oct 4, 2023
Merged
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
32 changes: 23 additions & 9 deletions src/qz/ws/PrintSocketClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,34 @@ public void onMessage(Session session, Reader reader) throws IOException {
}
}

processMessage(session, json, connection, request);
}
catch(UnsatisfiedLinkError | LoaderException e) {
log.error("A component is missing or broken, preventing this feature from working", e);
sendError(session, UID, "Sorry, this feature is unavailable at this time");
//spawn thread to prevent long processes from blocking
final String tUID = UID;
new Thread(() -> {
try {
processMessage(session, json, connection, request);
}
catch(UnsatisfiedLinkError | LoaderException e) {
log.error("A component is missing or broken, preventing this feature from working", e);
sendError(session, tUID, "Sorry, this feature is unavailable at this time");
}
catch(JSONException e) {
log.error("Bad JSON: {}", e.getMessage());
sendError(session, tUID, e);
}
catch(InvalidPathException | FileSystemException e) {
log.error("FileIO exception occurred", e);
sendError(session, tUID, String.format("FileIO exception occurred: %s: %s", e.getClass().getSimpleName(), e.getMessage()));
}
catch(Exception e) {
log.error("Problem processing message", e);
sendError(session, tUID, e);
}
}).start();
}
catch(JSONException e) {
log.error("Bad JSON: {}", e.getMessage());
sendError(session, UID, e);
}
catch(InvalidPathException | FileSystemException e) {
log.error("FileIO exception occurred", e);
sendError(session, UID, String.format("FileIO exception occurred: %s: %s", e.getClass().getSimpleName(), e.getMessage()));
}
catch(Exception e) {
log.error("Problem processing message", e);
sendError(session, UID, e);
Expand Down