Message10136

Author mbakht
Recipients mbakht
Date 2015-07-02.00:00:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1435795240.97.0.142116249862.issue2374@psf.upfronthosting.co.za>
In-reply-to
Content
When a call is made from jython (2.7.0) code for connecting to RabbitMQ through pika.BlockingConnection, it results in the following error:

    _socket.error: [Errno 92] Protocol not available


The call to pika.BlockingConnection ends up calling the following block of code in pika
(https://github.com/pika/pika/blob/master/pika/adapters/base_connection.py#L195)


def _create_and_connect_to_socket(self, sock_addr_tuple):
        """Create socket and connect to it, using SSL if enabled.
        :returns: error string on failure; None on success
        """
        self.socket = socket.socket(sock_addr_tuple[0], socket.SOCK_STREAM, 0)


The last value passed in socket.socket(..) denotes the protocol number which is 0 in this case.

This code calls the socket method in jython's _socket.py (https://github.com/jythontools/jython/blob/master/Lib/_socket.py#L1456):


def socket(family=None, type=None, proto=None):
    return _socketobject(family, type, proto)


Since the python code made the call with proto value set to 0, that is the value that will be passed here to _socketobject.


Now, here is the code in _socketobject (https://github.com/jythontools/jython/blob/master/Lib/_socket.py#L1308):


class _socketobject(object):

    __doc__ = _realsocket.__doc__


    def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
        if _sock is None:
            _sock = _realsocket(family, type, proto)


proto still has the value 0 as it gets passed down to realsocket.


class _realsocket(object):

    def __init__(self, family=None, type=None, proto=None):
        # FIXME verify args are correct
        self.family = family
        self.type = type
        if proto is None:
            if type == SOCK_STREAM:
                proto = IPPROTO_TCP
            elif type == SOCK_DGRAM:
                proto = IPPROTO_UDP
        self.proto = proto



Since proto is not None, it does not get assigned the default value of TCP. This zero value eventually causes the "Protocol not available" error.
History
Date User Action Args
2015-07-02 00:00:40mbakhtsetmessageid: <1435795240.97.0.142116249862.issue2374@psf.upfronthosting.co.za>
2015-07-02 00:00:40mbakhtsetrecipients: + mbakht
2015-07-02 00:00:40mbakhtlinkissue2374 messages
2015-07-02 00:00:40mbakhtcreate