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

Request parameters get lost on ws requests on Tomcat 7 #553

Closed
papegaaij opened this issue Aug 9, 2012 · 5 comments
Closed

Request parameters get lost on ws requests on Tomcat 7 #553

papegaaij opened this issue Aug 9, 2012 · 5 comments

Comments

@papegaaij
Copy link

With a websocket request on, for example, "scotty/app/?0-1.IBehaviorListener.0-", the query parameters are lost, causing the request to be handled as if it was "scotty/app/". This breaks wicket-atmosphere, because it needs the parameters to resolve the behavior that handles the ws requests. I'm not sure if this a bug in Tomcat or Atmosphere.

I've tried debugging the problem, but it's not clear to me how it is supposed to work. The parameters are available when AtmosphereServlet.event is called. After this method, I've stepped all the way down to CoyoteAdapter.service, which calls Request.recyle(), which clears the parameters. Next, going further down to Http11NioProtocol, TomcatWebSocketHandler.onUpgradeComplete get called, which in turn calls my servlet filter. It is passed an AtmosphereRequest that still contains the recycled Request with all parameters cleared.

@BugHunterPhilosopher
Copy link

I ran into this issue, too. I use wicket-atmosphere 6.0.0-beta3 which itself uses Atmosphere 1.0.0-beta3. And I use Tomcat 7.0.29.

As a workaround, I can fallback to Comet but if I could get WebSockets too, that would be great.

I'm looking forward to see this ticket evolve.

Regards,

Pierre

@jfarcand
Copy link
Member

OK looking at this. Stay tuned. I've also deleted the previous comments as this is a bug in Tomcat ;-)

@jfarcand
Copy link
Member

Hum, I cannot reproduce the issue using the Atmosphere's Chat sample with the URL of the form of

    var request = { url: document.location.toString() + 'chat?test=yo',
        contentType : "application/json",
        logLevel : 'debug',
        shared : 'true',
        transport : transport ,
        fallbackTransport: 'long-polling'};

which gets translated in

T 127.0.0.1:54228 -> 127.0.0.1:8080 [AP]
GET /atmosphere-chat/chat?test=yo&X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=1.0&X-Atmosphere-Transport=websocket&X-Cache-Date=0&Content-Type=application/json HTTP/1.1.
Upgrade: websocket.
Connection: Upgrade.
Host: 127.0.0.1:8080.
Origin: http://127.0.0.1:8080.
Sec-WebSocket-Key: 8NtGPiJuFA0ZuCbO9xxdAQ==.
Sec-WebSocket-Version: 13.
Sec-WebSocket-Extensions: x-webkit-deflate-frame.
Cookie: nikio.guid=e921455c-9487-4dbc-b5f1-ebb91d46e6e1.
.

Later, in any AtmosphereHandler, I do:

  AtmosphereResource.getRequest().getParametersName();

and I do see them. @papegaaij or @AlienQueen , can you share a test case?

@papegaaij
Copy link
Author

I've created a very small demo project for wicket-atmosphere: https://github.com/papegaaij/wicket-atmosphere-quickstart . The project depends on wicket-6.0.0, which is not yet officially released, until then you can get the latest snapshots with -Dwicket.version=6.0-SNAPSHOT -Dwicket.atmosphere.version=0.3-SNAPSHOT.

The difference between Tomcat and Jetty lies in HttpServletRequest.getQueryString(), as you can see in these log snippets, the query string is empty:

Jetty:
INFO  - DebugWicketFilter          - URI: AtmosphereRequest{ contextPath= servletPath=/app pathInfo=/ requestURI=/app/ requestURL=http://localhost:8081/app/ destroyable=false}
INFO  - DebugWicketFilter          - PAR: {X-Atmosphere-Transport=[websocket], X-Atmosphere-Framework=[1.0], X-Atmosphere-tracking-id=[0], 0-IResourceListener.0-=[], X-Cache-Date=[0]}
INFO  - DebugWicketFilter          - QUE: 0-IResourceListener.0-&X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=1.0&X-Atmosphere-Transport=websocket&X-Cache-Date=0

Tomcat:
INFO  - DebugWicketFilter          - URI: AtmosphereRequest{ contextPath=/myproject-1.0-SNAPSHOT servletPath=/app pathInfo=/ requestURI=/myproject-1.0-SNAPSHOT/app/ requestURL=http://localhost:8080/myproject-1.0-SNAPSHOT/app/ destroyable=false}
INFO  - DebugWicketFilter          - PAR: {X-Atmosphere-Transport=[websocket], X-Atmosphere-Framework=[1.0], X-Atmosphere-tracking-id=[0], 0-IResourceListener.0-=[], X-Cache-Date=[0]}
INFO  - DebugWicketFilter          - QUE: 

@jfarcand
Copy link
Member

Salut, OK got it! Fixing it now. A workaround is to use the getParametersXXX, but fixing it is simple.

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

No branches or pull requests

3 participants