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

Enhancement ssl websocket #6

Merged
merged 7 commits into from Dec 3, 2018

Conversation

fakufaku
Copy link
Contributor

@fakufaku fakufaku commented Nov 2, 2018

Hi, thanks for a great project!

I have added basic support to connect to secure websockets via the ussl module. There were also some minor changes to make here and there because of different api for ssl sockets compared to regular sockets (send and recv are not available and read and write need to be used instead).

I have also added commands in the Makefile to create the sub-directories and also clean up everything.

I'd be grateful if you review the code and let me know of fixes and modifications that would allow it to be merged.

Cheers!

Copy link
Owner

@danni danni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small changes. Make SSL available on more ports. Is it worth supporting http/https as protocol names?

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
uwebsockets/protocol.py Outdated Show resolved Hide resolved
@@ -58,7 +66,7 @@ class Websocket:
is_client = False

def __init__(self, sock):
self._sock = sock
self.sock = sock
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this?

Copy link
Contributor Author

@fakufaku fakufaku Nov 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I did this is that I was trying to port to the ESP32 a project that uses websocket-client and in this case the client has sock as attribute. Using the same attribute name makes it more compatible.
If that's the prefered way, I can revert to _sock and modify my port of the other library instead. Please let me know which is best.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay that's a good reason.

uwebsockets/client.py Show resolved Hide resolved
@fakufaku
Copy link
Contributor Author

fakufaku commented Nov 5, 2018

Thank you for the feedback. I replied to the comments individually and posted an updated version.

Copy link
Owner

@danni danni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. One more bit of feedback.

host = match.group(2)
port = match.group(3)
path = match.group(4)
protocol, host, port, path = [match.group(i) for i in range(1, 5)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

range is weird here. Just use the group names I think. It's more lucid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One line was too long, so I just put it back on separate lines.

@fakufaku
Copy link
Contributor Author

fakufaku commented Nov 5, 2018

Thanks. I added one extra small change which is to close the websockets at the end of examples/echo_websocket_org.py and examples/echo_ssl_websocket_org.py. I found out that opening more than one SSL socket on the ESP32 causes an out-of-memory error (this has been documented before). Thus, running twice the ssl example without closing the socket would crash the board.

@fakufaku
Copy link
Contributor Author

fakufaku commented Dec 3, 2018

@danni , ping 😄 Any chance you had time to review the changes ? Cheers!

@danni danni merged commit 0034cde into danni:esp8266 Dec 3, 2018
@danni
Copy link
Owner

danni commented Dec 3, 2018

Sorry, I missed the notification for this. Done! Thanks!

@fakufaku
Copy link
Contributor Author

fakufaku commented Dec 3, 2018

No worries, thanks a lot!

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

Successfully merging this pull request may close these issues.

None yet

2 participants