Skip to content

Commit

Permalink
added wss:// support to the client by wrapping WebSocketClient.sock u…
Browse files Browse the repository at this point in the history
…sing ssl.wrap_socket
  • Loading branch information
EliAndrewC committed Nov 23, 2011
1 parent 6e98772 commit b83caf2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ws4py/client/threadedclient.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import os
import ssl
from urlparse import urlsplit
import socket
import threading
Expand Down Expand Up @@ -44,6 +45,9 @@ def connect(self):
host, port = parts.netloc.split(':')
self.sock.connect((host, int(port)))

if parts.scheme == "wss":
self.sock = ssl.wrap_socket(self.sock)

self.write_to_connection(self.handshake_request)

response = ''
Expand Down

2 comments on commit b83caf2

@gmixo
Copy link

@gmixo gmixo commented on b83caf2 Mar 22, 2012

Choose a reason for hiding this comment

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

nice patch but i guess you forget one more thing

    if parts.scheme == "wss":
        self.sock = ssl.wrap_socket(self.sock

        self.sender = self.sock.write
        self.sock.recv = self.sock.read

perhaps for wss server need to do similar correction

@gmixo
Copy link

@gmixo gmixo commented on b83caf2 Mar 23, 2012

Choose a reason for hiding this comment

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

sorry for writting here) i have realized wss server using ws4py but it looks very strange
I understand ssl.SSLSocket send\recv works only with string not bytearray and
for sending string 'abcd' it must looks like '\x82\x06abcd\r'

Please sign in to comment.