Java SSLSocket在新连接后写入SocketException

时间:2015-04-01 08:28:25

标签: java sockets ssl connection imap

这是我的代码:

            Socket s = server.accept();
            s.setSoTimeout(1000);
            DataOutputStream out = new DataOutputStream(s.getOutputStream());
            out.flush();
            DataInputStream in = new DataInputStream(s.getInputStream());
            System.out.println(s.isClosed());
            out.write(("* OK " + ((String)host.getConfig().get("domain")).split(",")[0] + " IMAP ready." + crlf).getBytes());
            out.flush();
            host.addWorkIMAP(s, in, out, server instanceof SSLServerSocket);

在写入字符串的行上,我得到java.net.SocketException: Software caused connection abort: recv failed

(服务器是SSLServerSocket)。

我知道套接字未关闭,因为对isClosed()的调用返回false。此外,Thunderbird在出现此错误后超时(我正在编写IMAP服务器)。

堆栈追踪:

[12:54:54] java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:422)
at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:460)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:863)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.waitForClose(SSLSocketImpl.java:1571)
at com.sun.net.ssl.internal.ssl.HandshakeOutStream.flush(HandshakeOutStream.java:103)
at com.sun.net.ssl.internal.ssl.Handshaker.sendChangeCipherSpec(Handshaker.java:689)
at com.sun.net.ssl.internal.ssl.ServerHandshaker.sendChangeCipherAndFinish(ServerHandshaker.java:1279)
at com.sun.net.ssl.internal.ssl.ServerHandshaker.clientFinished(ServerHandshaker.java:1239)
at com.sun.net.ssl.internal.ssl.ServerHandshaker.processMessage(ServerHandshaker.java:225)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:593)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:529)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:943)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1188)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:654)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:100)
at java.io.DataOutputStream.write(DataOutputStream.java:90)
at java.io.FilterOutputStream.write(FilterOutputStream.java:80)
at mail.smtp.ThreadAcceptSMTP.run(ThreadAcceptSMTP.java:65)

0 个答案:

没有答案