Huzaifa Tapal
huzaifa at hostway.com
Wed Apr 27 15:43:43 EDT 2005
Also, addiitional information from my research. Here is the where the error is generated: def connect(self): "Connect to a host on a given (SSL) port." sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((self.host, self.port)) ssl = socket.ssl(sock, self.key_file, self.cert_file) self.sock = FakeSocket(sock, ssl) based on the error and tcpdump, the socket is created fine, the connection is using the socket is made fine, the error occurs on calling ssl() method of the socket class. def ssl(sock, keyfile=None, certfile=None): if hasattr(sock, "_sock"): sock = sock._sock return _realssl(sock, keyfile, certfile) above is what the ssl method on the modular level looks like. The funny part is that the _sock attribute on the sock object has to be _sock.sock in order for connect() to work. And we know that works since I see tcpdump connections being made without a problem. Whats wierd is that when the sock object is passed to the ssl() method, that is when it somehow gets corrupted and the _sock attribute turns from _sock.sock type to _sockobject() type. Hozi Huzaifa Tapal wrote: > Hello Dan, > > I have been doing some research and we checked tcpdump and netstats > while the error is happening and there are no socket connections > open. Is there a thread safety issue in httplib and socket? What > concerns me is that the ssl() method in socket.py is at the global > level meaning that the somehow the sockets are being changed by > multiple threads. > > hozi > > Dan Nelson wrote: > >> If it's working for a while and then you get an error, perhaps it has >> something to do with apache reaching some limit, queueing/caching, >> too many threads, too many sockets... That might be a place to start >> looking. >> >> Dan >> >> >> ----- Original Message ----- From: "Huzaifa Tapal" <huzaifa at hostway.com> >> To: <mod_python at modpython.org> >> Sent: Thursday, 21 April, 2005 2:56 AM >> Subject: [mod_python] SSL Socket Problem >> >> >>> Hello All, >>> >>> I am having a problem with making SSL socket connections in my >>> mod_python application running with python 2.3.5. The error I keep >>> getting back is "TypeError: ssl() argument 1 must be _socket.socket, >>> not _socketobject". What is odd is that if I restart the apache2 web >>> server, the error goes away and all the calls return back with a >>> message. However, after about 20 or so minutes we start getting >>> this error almost instantaneously without any kind of message going >>> out at all. >>> >>> Here is the full traceback: >>> >>> con.endheaders() >>> File "/usr/lib/python2.3/httplib.py", line 715, in endheaders >>> self._send_output() >>> File "/usr/lib/python2.3/httplib.py", line 600, in _send_output >>> self.send(msg) >>> File "/usr/lib/python2.3/httplib.py", line 567, in send >>> self.connect() >>> File "/usr/lib/python2.3/httplib.py", line 988, in connect >>> ssl = socket.ssl(sock, self.key_file, self.cert_file) >>> File "/usr/lib/python2.3/socket.py", line 73, in ssl >>> return _realssl(sock, keyfile, certfile) >>> TypeError: ssl() argument 1 must be _socket.socket, not >>> _socketobject >>> >>> I have the same application running on another machine with python >>> 2.3.4 and I can't replicate it in there. Do you guys know of any >>> known issues with sockets and ssl with python 2.3.5? >>> >>> Any help would be appreciated. >>> >>> Hozi >>> >>> _______________________________________________ >>> Mod_python mailing list >>> Mod_python at modpython.org >>> http://mailman.modpython.org/mailman/listinfo/mod_python >>> >> >> > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python > >
|