当我在glassfish中编写代码时,我得到javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake error
,它与java运行良好......
完整堆栈跟踪:
2016-01-27T17:26:47.078+0100|Avertissement: Caught exception executing step: com.ibm.jbatch.container.exception.BatchContainerRuntimeException: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at com.ibm.jbatch.container.artifact.proxy.BatchletProxy.process(BatchletProxy.java:36)
at com.ibm.jbatch.container.impl.BatchletStepControllerImpl.invokeBatchlet(BatchletStepControllerImpl.java:79)
at com.ibm.jbatch.container.impl.BatchletStepControllerImpl.invokeCoreStep(BatchletStepControllerImpl.java:107)
at com.ibm.jbatch.container.impl.BaseStepControllerImpl.execute(BaseStepControllerImpl.java:144)
at com.ibm.jbatch.container.impl.ExecutionTransitioner.doExecutionLoop(ExecutionTransitioner.java:112)
at com.ibm.jbatch.container.impl.JobThreadRootControllerImpl.originateExecutionOnThread(JobThreadRootControllerImpl.java:110)
at com.ibm.jbatch.container.util.BatchWorkUnit.run(BatchWorkUnit.java:80)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.glassfish.enterprise.concurrent.internal.ManagedFutureTask.run(ManagedFutureTask.java:141)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
at org.glassfish.enterprise.concurrent.ManagedThreadFactoryImpl$ManagedThread.run(ManagedThreadFactoryImpl.java:250)
Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:946)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:702)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:122)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at javaeetutorial.batch.webserverlog.---
at com.ibm.jbatch.container.artifact.proxy.BatchletProxy.process(BatchletProxy.java:33)
... 13 more
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at sun.security.ssl.InputRecord.read(InputRecord.java:482)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
... 23 more
我已经花了3天时间阅读所有帖子。是否与此有关:https://java.net/jira/browse/GLASSFISH-21416?
修改
这就是代码:(它在writer.flush
的玻璃鱼中崩溃)
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import javax.net.ssl.*;
public class Test {
// substitute your own username and password
private static final String initiation_command = "live username ***** password *******" + "\n";
public static void main(String[] args) {
String machineName = "firehose.flightaware.com";
int port = 1501;
RunClient(machineName, port);
System.out.println(" Thank you for using FlightAware ... bye now");
}
public static void RunClient(String machineName, int port) {
System.out.println(" Running Client");
try {
SSLSocket ssl_socket;
ssl_socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(machineName, port);
// enable certifcate validation:
SSLParameters sslParams = new SSLParameters();
sslParams.setEndpointIdentificationAlgorithm("HTTPS");
ssl_socket.setSSLParameters(sslParams);
//send your initiantion command
OutputStreamWriter writer = new OutputStreamWriter(ssl_socket.getOutputStream(), "UTF8");
writer.write(initiation_command);
writer.flush();
// read messages from FlightAware
BufferedReader reader = new BufferedReader(new InputStreamReader(ssl_socket.getInputStream()));
String message = null;
int limit = 10; //limit number messages for testing
while (limit > 0 && (message = reader.readLine()) != null) {
System.out.println("msg: " + message);
}
//done, close everything
writer.close();
reader.close();
ssl_socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}