Hendy Irawan created WICKET-5280:
------------------------------------
Summary: HttpsMapper Could not resolve protocol for request
"WebSocket"
Key: WICKET-5280
URL: https://issues.apache.org/jira/browse/WICKET-5280
Project: Wicket
Issue Type: Bug
Components: wicket, wicket-atmosphere
Affects Versions: 6.9.1
Environment: wicket-atmosphere 0.11, Tomcat 7.0
Reporter: Hendy Irawan
Assignee: Emond Papegaaij
HttpsMapper, with or without XForwardedRequestWrapper, seems to be problematic
when combined with Atmosphere via WebSocket :
{code}
java.lang.IllegalStateException
Could not resolve protocol for request:
org.apache.wicket.protocol.http.servlet.XForwardedRequestWrapper@cbb5077
{code}
Or without XForwardedRequestWrapper:
{code}
java.lang.IllegalStateException
Could not resolve protocol for request: c244911c-d8aa-4d66-a645-2ef935199b78
at
org.apache.wicket.protocol.https.HttpsMapper.getSchemeOf(HttpsMapper.java:215)
~[wicket-core-6.9.1.jar:6.9.1]
at
org.apache.wicket.protocol.https.HttpsMapper.mapHandler(HttpsMapper.java:167)
~[wicket-core-6.9.1.jar:6.9.1]
at
org.apache.wicket.protocol.https.HttpsMapper.mapHandler(HttpsMapper.java:112)
~[wicket-core-6.9.1.jar:6.9.1]
{code}
although page "seems" operating normally, but it gives ERROR logs.
I think this is due to Atmosphere & HttpsMapper not detecting the scheme
correctly? (ws/wss? actually "WebSocket")
{code}
protected Scheme getSchemeOf(Request request)
{
HttpServletRequest req = (HttpServletRequest)
request.getContainerRequest();
if ("https".equalsIgnoreCase(req.getScheme()))
{
return Scheme.HTTPS;
}
else if ("http".equalsIgnoreCase(req.getScheme()))
{
return Scheme.HTTP;
}
else
{
throw new IllegalStateException("Could not resolve
protocol for request: " + req);
}
}
{code}
I workaround it using:
{code}
setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new
HttpsConfig(8980, 8943)) {
@Override
protected Scheme getSchemeOf(Request request) {
HttpServletRequest req = (HttpServletRequest)
request.getContainerRequest();
log.info("Scheme for {} is {}", req, req.getScheme());
if ("https".equalsIgnoreCase(req.getScheme()))
{
return Scheme.HTTPS;
}
else if ("http".equalsIgnoreCase(req.getScheme()))
{
return Scheme.HTTP;
}
else if ("WebSocket".equalsIgnoreCase(req.getScheme()))
{
return Scheme.ANY;
}
else
{
throw new IllegalStateException("Could not resolve
protocol for request: " + req
+ ", unrecognized scheme: " +
req.getScheme());
}
}
});
{code}
If the above is proper way to do it, please update the {{HttpsMapper}}
implementation, also with more detailed exception message above ("unrecognized
scheme").
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira