You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Andres Martinez Quijano (JIRA)" <ji...@apache.org> on 2013/11/28 14:49:36 UTC

[jira] [Comment Edited] (DIRMINA-907) Create a WebSocket iofilter for use in Apache Mina TCP servers

    [ https://issues.apache.org/jira/browse/DIRMINA-907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13834843#comment-13834843 ] 

Andres Martinez Quijano edited comment on DIRMINA-907 at 11/28/13 1:49 PM:
---------------------------------------------------------------------------

After a loooong time debugging I found another bug, that happens only on very specific messages.

in WebSocketEncoder.buildWSDataFrameBuffer it creates a new buffer and around line 66, when setting the payload length it is:

{code:title=WebSocketEncoder.java|borderStyle=solid}
if (buffer.capacity() <= 125) {
{code}

but it should be:

{code:title=WebSocketEncoder.java|borderStyle=solid}
if (buf.capacity() <= 125) {
{code}

since otherwise it's checking on the size of the newly created buffer (which includes the 2 extra header bytes) and as such when the original payload is of size 124 or 125 it will use 2 bytes as payload length, which makes the browser complain and close the connection [http://tools.ietf.org/html/rfc6455#section-5.2]

Also the code doesn't implement extended payload length, but I don't think that's a problem, since that only applies to *huge* messages


was (Author: quixote_arg):
After a loooong time debugging I found another bug, that happens only on very specific messages.

in WebSocketEncoder.buildWSDataFrameBuffer it creates a new buffer and around line 66, when setting the payload length it is:

{code:title=WebSocketEncoder.java|borderStyle=solid}
if (buffer.capacity() <= 125) {
{code}

but it should be:

{code:title=WebSocketEncoder.java|borderStyle=solid}
if (buf.capacity() <= 125) {
{code}

since otherwise it's checking on the size of the newly created buffer (which includes the 2 extra header bytes) and as such when the original payload is of size 124 or 125 it will use 2 bytes as payload length, which makes the browser complain and close the connection [http://tools.ietf.org/html/rfc6455#section-5.2]

> Create a WebSocket iofilter for use in Apache Mina TCP servers
> --------------------------------------------------------------
>
>                 Key: DIRMINA-907
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-907
>             Project: MINA
>          Issue Type: New Feature
>          Components: Filter, Protocol - HTTP, Transport
>            Reporter: dhruv chopra
>         Attachments: MinaCodecUsage.png, WebSocketFilter.zip
>
>
> Shephertz has created a websocket iofilter that can be added in Apache mina tcp server chain. The features of this codec are
> 1) Works with binary data sent/received over websocket
> 2) Abstracts the client details from the Handler code i.e. the handler need not be aware that the remote endpoint is a browser or native client.
> 3) Tested with binary data sent/received on latest chrome and firefox browsers. IE 9 doesn't support websockets and we will make changes if required for IE 10 when its released and if it supports websockets.



--
This message was sent by Atlassian JIRA
(v6.1#6144)