Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 6.1.6rc1
-
Fix Version/s: 7.0.0pre4, 6.1.12.rc2
-
Component/s: Bayeux
-
Labels:None
-
Environment:Winxp
-
Number of attachments :
Description
I always meet this problem. Actually, when I use Http , not Https, and SelectChannelConnector , it is no problem to publish event from server to client or request from client to server. But when I start a servlet with SslSelectChannelConnector and then start client to connect it , the "WARN: Handshake:org.mortbay.jetty.EofException" always thrown. Maybe it is not a bug for Bayeux, but could u tell me how to resolve it?
The fllowing is the output of console:
[main] : CometdSSLClient------Beginning to start Client...
2007-12-19 10:32:38.746::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
[main] : CometdSSLClient------Start BayeuxClient:null
[main] : CometdSSLClient------Start Client successfully!
[main] : CometdSSLClient------clientPublish toChannel:/noticiation/tier3 data:
msgId:0
2007-12-19 10:32:38.011::WARN: Handshake:org.mortbay.jetty.EofException
org.mortbay.jetty.EofException
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:303)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
at org.mortbay.jetty.client.HttpConnection.handle(HttpConnection.java:238)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
The below is a part of my sourcecodes in client and servlet, and I have attched the BayeuxClient.java in attachment.
Server side:
...
public void startCometdSSLServlet() {
try {
Logger.log(Logger.LOG_NORMAL, "Beginning to start CometdSSLServlet...");
String sUserDir = System.getProperty("user.dir");
Server server = new Server();
SelectChannelConnector connector;
if (_sslEnabled.equalsIgnoreCase("Y"))
else
{ connector = new SelectChannelConnector(); }
connector.setPort(_sPort);
server.addConnector(connector);
//System.setProperty("javax.net.ssl.trustStore", _sKeystore);
Context context = new Context(server, "/", Context.NO_SECURITY | Context.NO_SESSIONS);
context.setResourceBase(sUserDir + "/myweb/");
ContinuationCometdServlet cometd_servlet = new ContinuationCometdServlet();
ServletHolder cometd_holder = new ServletHolder(cometd_servlet);
//cometd_holder.setInitParameter("filters","/WEB-INF/filters.json");
cometd_holder.setInitParameter("timeout", "240000");
cometd_holder.setInitParameter("interval", "0");
cometd_holder.setInitParameter("multiFrameInterval", "1500");
//cometd_holder.setInitParameter("JSONCommented","true");
//context.addServlet(cometd_holder, "/cometd/*");
context.addServlet(cometd_holder, "/myweb/*");
context.addServlet("servlet.DefaultHttpServlet", "/");
_listener = new BayeuxCometdStartupListener();
context.addEventListener(_listener);
server.start();
AbstractBayeux bayeux = cometd_servlet.getBayeux();
bayeux.setSecurityPolicy(new AbstractBayeux.DefaultPolicy() {
public boolean canHandshake(Map message) {
System.err.println("BayeuxServlet-------------------canHandshake(Message)");
// if (_testHandshakeFailure < 0)
return true;
}
});
Logger.log(Logger.LOG_NORMAL, "CometdSSLServlet start successfully!");
} catch (Exception ex)
}
public void pushEvent(Map<String, Object> msg)
{ _listener.pushDebugEvent(msg); } public static void main(String[] args) {
CometdSSLServlet cometServlet = CometdSSLServlet.getInstance();
cometServlet.startCometdSSLServlet();
int i = 0;
while (true) {
try
catch (InterruptedException ex)
{ ex.printStackTrace(); } }
}
...
client side:
.....
private void start() {
Logger.log(Logger.LOG_NORMAL, "CometdSSLClient------Beginning to start Client...");
try {
try
catch (Exception ex)
{ Logger.log(Logger.LOG_ERR, "CometdSSLClient------Start HttpClient error"); ex.printStackTrace(); } startBayeuxClient();
} catch (IOException ex)
Logger.log(Logger.LOG_NORMAL, "CometdSSLClient------Start Client successfully!");
}
private void startHttpClient() throws Exception
{ _httpClient = new HttpClient(); _httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); _httpClient.setMaxConnectionsPerAddress(MAX_CONNECTION_PERADDRESS); BoundedThreadPool pool = new BoundedThreadPool(); pool.setMaxThreads(MAX_THREAD); //pool.setDaemon(true); pool.setName("COMETDCLIENT_HREADPOOL"); _httpClient.setThreadPool(pool); _httpClient.start(); } private void startBayeuxClient() throws IOException {
_bClient = new BayeuxClient(_httpClient, _address, _uri, _isHttps);
Listener listener = new Listener() {
public void deliver(Client fromClient, Client toClient, Map<String, Object> msg) {
Logger.log(Logger.LOG_DEBUG, "CometdSSLClient------------Get Time:" + (new Date()));
Logger.log(Logger.LOG_DEBUG, "CometdSSLClient------------FromClient:" + fromClient + " toClient:" + toClient.getId() + " Message:" + msg);
Object data = (Object) msg.get(AbstractBayeux.DATA_FIELD);
//filtered the "/meta/channel" connection information and only keep "/service/channel" and "/notification/channel" message.
if (data != null)
}
public void removed(String clientId, boolean timeout) {
}
};
_bClient.setListener(listener);
_bClient.subscribe(Configurator.CLIENT_NOTIFICATIONCHANNEL);
_bClient.start();
Logger.log(Logger.LOG_NORMAL, "CometdSSLClient------Start BayeuxClient:" + _bClient.getId());
}
private void clientPublish(String toChannel, JSON.Literal jsonMsg, String msgId) {
synchronized (_bClient)
}
/**
- @param clientType
- please see CometdConfigurator.CLIENT_NOTIFICATION, CometdConfigurator.CLIENT_SERVICE
*/
public void registerClient(String clientType)Unknown macro: { // TODO }
public static void main(String[] args) {
CometdSSLClient sslClient = CometdSSLClient.getInstance();
sslClient.start();
sslClient.registerClient(Configurator.CLIENT_NOTIFICATIONCHANNEL);
}
......
Activity
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Greg Wilkins [ gregw ] |
| Assignee | Greg Wilkins [ gregw ] |
| Assignee | Greg Wilkins [ gregw ] |
| Fix Version/s | 6.1.12 [ 14380 ] | |
| Fix Version/s | 7.0.0pre3 [ 14417 ] |
| Fix Version/s | 7.0.0pre3 [ 14417 ] | |
| Fix Version/s | 7.0.0pre4 [ 14494 ] |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
| Fix Version/s | 6.1.12 [ 14380 ] | |
| Fix Version/s | 6.1.12.rc2 [ 14574 ] |
The Servlet output as below:
init:
deps-jar:
Deleted 13 out of date files in 0 seconds
Compiling 4 source files to C:\SCG\Jetty\jetty-6.1.6rc1\jetty-6.1.6rc1\contrib\cometd\demo\src\main\build\classes
Note: C:\SCG\Jetty\jetty-6.1.6rc1\jetty-6.1.6rc1\contrib\cometd\demo\src\main\java\client\BayeuxClient.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
compile:
[main] : CometdSSLServlet userdir=C:\SCG\Jetty\jetty-6.1.6rc1\jetty-6.1.6rc1\contrib\cometd\demo\src\main
[main] : Beginning to start CometdSSLServlet...
2007-12-19 15:22:12.686::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
2007-12-19 15:22:12.764::INFO: jetty-6.1.6rc1
2007-12-19 15:22:12.029::INFO: Started SslSelectChannelConnector@0.0.0.0:8443
[main] : CometdSSLServlet start successfully!