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

Exception in ssl wrapper when used in Kodi - possible fix #241

Open
large opened this issue Feb 13, 2018 · 0 comments
Open

Exception in ssl wrapper when used in Kodi - possible fix #241

large opened this issue Feb 13, 2018 · 0 comments

Comments

@large
Copy link

large commented Feb 13, 2018

Hi! I have used the ws4py in Kodi and works great without SSL.

But it crash with SSL, like this:

                                          File "C:\Kodi\addons\script.motr\resources\lib\ws4py\client\__init__.py", line 214, in connect
                                            self.sock = ssl.wrap_socket(self.sock, **self.ssl_options)
                                          File "C:\Kodi\system\python\Lib\ssl.py", line 943, in wrap_socket
                                            ciphers=ciphers)
                                          File "C:\Kodi\system\python\Lib\ssl.py", line 590, in __init__
                                            self.getpeername()
                                          File "C:\Kodi\system\python\Lib\socket.py", line 228, in meth
                                            return getattr(self._sock,name)(*args)
                                        error: [Errno 10057] En foresp�rsel om � sende eller motta data ble forkastet fordi socketen ikke er tilkoblet og (ved sending p� en datagramsocket som bruker et sendto-kall) ingen adresse var angitt
                                        -->End of Python script error report<--

After checking the error, I changed the ws4py\client_init_.py line 207 in connect()

As found:

    def connect(self):
        """
        Connects this websocket and starts the upgrade handshake
        with the remote endpoint.
        """
        if self.scheme == "wss":
            # default port is now 443; upgrade self.sender to send ssl
            self.sock = ssl.wrap_socket(self.sock, **self.ssl_options)
            self._is_secure = True
        **self.sock.connect(self.bind_addr)**
        self._write(self.handshake_request)
(...)

As left:

    def connect(self):
        """
        Connects this websocket and starts the upgrade handshake
        with the remote endpoint.
        """
        
        #FIX? To make the WSS work, connect and then warp: 13.02.18 Lars Werner
        **self.sock.connect(self.bind_addr)**
        
        if self.scheme == "wss":
            # default port is now 443; upgrade self.sender to send ssl
            self.sock = ssl.wrap_socket(self.sock, **self.ssl_options)
            self._is_secure = True

        self._write(self.handshake_request)
(...)

I'm not a great Python coder (just used it for a couple of weeks) but it seems to work perfectly by doing so. And it upgrades the socket to SSL as it should.

Any comments on this easy "fix"?

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
@large and others