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

Java版本套接字调用 Software caused connection abort: socket write error #106

Open
monawolf opened this issue May 16, 2024 · 0 comments

Comments

@monawolf
Copy link

monawolf commented May 16, 2024

Java版本调用时,Ocr.class#sendJsonToOcr,writer.write(sw.getBuffer().toString());前面添加一段
if (OcrMode.SOCKET_SERVER == mode) {
writer.close();
reader.close();
clientSocket.close();
clientSocket = new Socket(serverAddr, serverPort);
clientSocket.setKeepAlive(true);
reader = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(), StandardCharsets.UTF_8));
writer = new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream(), StandardCharsets.UTF_8));
}
长连接第二次调用时会导致 Software caused connection abort: socket write error,所以套接字启动时改为短连接比较好

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant