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

MAX_RW_BUF_LEN not large enough for WebSocketConnection::WssHandshake #46

Closed
sjmh3 opened this issue Oct 20, 2017 · 5 comments
Closed

Comments

@sjmh3
Copy link

sjmh3 commented Oct 20, 2017

The WSS HTTP GET request formed in WebSocketConnection::WssHandshake can exceed 2048 bytes, which is the size of MAX_RW_BUF_LEN. The error traced out is that the WSS handshake fails because there are no SSL packets to read. In fact the request has only been partially written because the buffer wasn't large enough to hold all of it in one go, so the IoT service hasn't sent a response.

@vareddy-zz
Copy link
Contributor

Hi @sjmh3 ,
Thank you for your interest in the AWS IoT SDK!
Were you able to increase the MAX_RW_BUF_LEN to successfully complete the WSS handshake? If yes, what was the value of the buffer that was required for it?
We will investigate this on our end and provide a fix for this.
Thanks!
Varun

@sjmh3
Copy link
Author

sjmh3 commented Oct 22, 2017

Hi @vareddy,
Yes, increasing MAX_RW_BUF_LEN allowed me to successfully complete the WSS handshake. I should have said what buffer size was required - sorry. I increased the buffer size to 3072 and then in WebSocketConnection::WssHandshake() I saw the length of the request string stored in rw_buf range from 2048 to 2088 (as returned from strnlen), so that would require MAX_RW_BUF_LENto be up to 2089. I'm always connecting to the same endpoint, so the variable length comes from the canonical query string. I haven't investigated what causes its length to vary so can't say if 2089 would be sufficient for all situations.
The original buffer size of 2048 was large enough for my request string a couple of months ago with the same code; I only started hitting this problem when returning to the project this week. So something about the request is longer now than it was then.
Simon

@vareddy-zz
Copy link
Contributor

Hi @sjmh3 ,
While connecting over WebSockets, did you fill in the "aws_session_token" in the configuration?
Thanks!
Varun

@sjmh3
Copy link
Author

sjmh3 commented Nov 3, 2017

Hi @vareddy,

Yes, I did fill in the session token - do I not need to?

Thanks,
Simon

@vareddy-zz
Copy link
Contributor

Hi @sjmh3 ,
That would explain the overshoot as it can easily be over 2k if you fill in the session token. That is more like oversight on our part. I have made a fix and will be pushing to master after our internal testing.
Thanks!
Varun

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