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

Fragment Size is not buffer size #395

Closed
SergeVL opened this issue Jun 26, 2018 · 12 comments
Closed

Fragment Size is not buffer size #395

SergeVL opened this issue Jun 26, 2018 · 12 comments

Comments

@SergeVL
Copy link

SergeVL commented Jun 26, 2018

Really I can't find size of message when Chrome starts using fragmentation, but I hope
it exists. Anyway it is not 4K.

But in accordance with RFC6455:

A sender MAY create fragments of any size for non-control
messages.

Your implementation limits the size of the fragment to the size of the buffer (by default 4K).
As a result traefik proxy server can't send to backend messages longer then 4K.

@garyburd
Copy link
Contributor

This package can send a message of any size and will fragment messages in some circumstances. As the quote from the RFC states, message fragmenting is allowed.

This package can receive a message of any size, independent of any fragmenting.

If the traefik server cannot handle fragmented messages, then report the issue with the traefik server.

@SergeVL
Copy link
Author

SergeVL commented Jun 28, 2018

Sorry.
I use websocket for sending documents to a editor in browser and back to server.
Sending to browser is without problems. I assume that python websocket implementation uses a fragmentation.
But on sending from browser to server packet was trimmed by traefik proxy (when working without proxy problem absent).
When I increased the defaultReadBufferSize and defaultWriteBufferSize in gorilla/websocket/conn.go the problem disappeared. But appeared again with larger than buffer size document.
And traefik use yours last version code.

@garyburd
Copy link
Contributor

This package does not trim messages. Based on a quick look at the traefik code, I don't see anything there that will trim a message. It sounds like the backend server does not support fragmented messages. What is the backend server?

@SergeVL
Copy link
Author

SergeVL commented Jun 28, 2018

When working without proxy problem absent.
On the backend side gevent-websocket. Citation:
`
def read_message(self):

message = bytearray()

while(True):

    header, payload = self.read_frame()
    
    ...

   message += payload

   if header.fin:

            break

return message

`

@SergeVL
Copy link
Author

SergeVL commented Jun 28, 2018

And:
header.fin = first_byte_in_frame & FIN_MASK == FIN_MASK
FIN_MASK = 0x80

@garyburd
Copy link
Contributor

Does gevent-websocket report an error when reading the fragmented message? Can the application continue to read the websocket after reading the fragmented message?

@garyburd garyburd reopened this Jun 28, 2018
@garyburd
Copy link
Contributor

garyburd commented Jun 28, 2018

Here's what we know:

  • OP has application with browser <-> Traefik <-> backend application that uses gevent_websocket.
  • Traefik uses this package.
  • When messages are fragmented between Traefik and backend application , the application receives "trimmed" messages.

Next step:

  • Test this package with echo server written with gevent_websocket. If fragmented messages do not work in this scenario, then debug the problem. Otherwise, close the issue.

I do not have time to work on this (see #370).

Edit: gevent_websocket has an echo example and this package has an echo client. Modify the echo client to send messages larger than the write buffer size and to check that received message have the expected length.

@elithrar
Copy link
Contributor

elithrar commented Jun 29, 2018 via email

@SergeVL
Copy link
Author

SergeVL commented Jun 29, 2018

Does gevent-websocket report an error when reading the fragmented message?

No. Because payload is json I had error in json parsing.

Can the application continue to read the websocket after reading the fragmented message?

Not sure. websocket package behind socket.io that could reconect on error disconecting. But in js console nothing.

@elithrar
Copy link
Contributor

@SergeVL

Can you document the parts at play here? Where does socket.io fit in, since this is the first time you’ve mentioned it. Diagram (ASCII is OK) would be great.

I want to spin up the same client, Traefik, gevent backend to replicate this first. We need a standalone repro with an echo backend, and then we can look at Traefik & client-side by process of elimination.

@SergeVL
Copy link
Author

SergeVL commented Jun 30, 2018

I will make some test/simplified environment

@garyburd
Copy link
Contributor

Closing because no response from OP in a month.

@gorilla gorilla locked and limited conversation to collaborators Apr 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants