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

contentLength and ReadMaxPayloadSize mismatch #84

Closed
prawnsalad opened this issue Apr 21, 2024 · 4 comments
Closed

contentLength and ReadMaxPayloadSize mismatch #84

prawnsalad opened this issue Apr 21, 2024 · 4 comments

Comments

@prawnsalad
Copy link

I'm trying to verify the ReadMaxPayloadSize config option but i can't quite make sense of it.

In readMessage() if I add print("contentLength = ", contentLength, " continuation? ", opcode == OpcodeContinuation, "\n") and then use this test script in Chrome:

w = new WebSocket('ws://localhost:5000/connect');
w.addEventListener('open', () => w.send('a'.repeat(1024)));

I would expect contentLength to be 1024. However, it prints contentLength = 11 continuation? false. Is there some unit mismatch or is it reading the contentLength incorrectly?

@lxzan
Copy link
Owner

lxzan commented Apr 21, 2024

Post the gws server configuration

@prawnsalad
Copy link
Author

gws.NewUpgrader(wsHandlers, &gws.ServerOption{
		ReadAsyncEnabled: true,         // Parallel message processing
		CompressEnabled:  true,         // Enable compression
		Recovery:         gws.Recovery, // Exception recovery
		ReadMaxPayloadSize: 1024,
		Logger: lt{},
	})

@lxzan
Copy link
Owner

lxzan commented Apr 21, 2024

The content is compressed

@prawnsalad
Copy link
Author

Ahh of course.. that makes sense! So ReadMaxPayloadSize is the protocol level max payload size. Now it makes sense and everything is good. Thank you!

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

No branches or pull requests

2 participants