title: PyHive Thrift transport exception: read 0 bytes
body: <p>I'm trying to connect to Hive server-2 running inside docker container (from outside the container) via python (PyHive 0.5, python 2.7) using <a href="https://github.com/dropbox/PyHive" rel="nofollow noreferrer">DB-API (asynchronous)</a> example</p>
  
  <pre><code>from pyhive import hive
  conn = hive.connect(host='172.17.0.2', port='10001', auth='NOSASL')
  </code></pre>
  
  <p>However, I'm getting following error</p>
  
  <pre><code>Traceback (most recent call last):
    File "py_2.py", line 4, in &lt;module&gt;
      conn = hive.connect(host='172.17.0.2', port='10001', auth='NOSASL')
    File "/home/foodie/anaconda2/lib/python2.7/site-packages/pyhive/hive.py", line 64, in connect
      return Connection(*args, **kwargs)
    File "/home/foodie/anaconda2/lib/python2.7/site-packages/pyhive/hive.py", line 164, in __init__
      response = self._client.OpenSession(open_session_req)
    File "/home/foodie/anaconda2/lib/python2.7/site-packages/TCLIService/TCLIService.py", line 187, in OpenSession
      return self.recv_OpenSession()
    File "/home/foodie/anaconda2/lib/python2.7/site-packages/TCLIService/TCLIService.py", line 199, in recv_OpenSession
      (fname, mtype, rseqid) = iprot.readMessageBegin()
    File "/home/foodie/anaconda2/lib/python2.7/site-packages/thrift/protocol/TBinaryProtocol.py", line 148, in readMessageBegin
      name = self.trans.readAll(sz)
    File "/home/foodie/anaconda2/lib/python2.7/site-packages/thrift/transport/TTransport.py", line 60, in readAll
      chunk = self.read(sz - have)
    File "/home/foodie/anaconda2/lib/python2.7/site-packages/thrift/transport/TTransport.py", line 161, in read
      self.__rbuf = BufferIO(self.__trans.read(max(sz, self.__rbuf_size)))
    File "/home/foodie/anaconda2/lib/python2.7/site-packages/thrift/transport/TSocket.py", line 132, in read
      message='TSocket read 0 bytes')
  thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
  </code></pre>
  
  <hr>
  
  <p>The docker image that I'm using is <a href="https://hub.docker.com/r/rohitbarnwal7/spark/tags/" rel="nofollow noreferrer">this</a> (tag: mysql_corrected).
  It runs following services (as outputted by jps command)</p>
  
  <pre><code>992 Master
  1810 RunJar
  259 DataNode
  2611 Jps
  584 ResourceManager
  1576 RunJar
  681 NodeManager
  137 NameNode
  426 SecondaryNameNode
  1690 RunJar
  732 HistoryServer
  </code></pre>
  
  <p>I'm launching the container using</p>
  
  <pre><code>docker run -it -p 8088:8088 -p 8042:8042 -p 4040:4040 -p 18080:18080 -p 10002:10002 -p 10000:10000 -e 3306 -e 9084 -h sandbox -v /home/foodie/docker/w1:/usr/tmp/test rohitbarnwal7/spark:mysql_corrected bash
  </code></pre>
  
  <p>Furthermore, I perform following steps to launch Hive server inside docker container</p>
  
  <ol>
  <li>Start mysql service: <code>service mysqld start</code></li>
  <li>Switch to directory /usr/local/hive: <code>cd $HIVE_HOME</code></li>
  <li>Launch Hive metastore server: <code>nohup bin/hive --service metastore &amp;</code></li>
  <li>Launch Hive server 2: <code>hive --service hive-server2</code> (note that thrift-server port is already changed to 10001 in <code>/usr/local/hive/conf/hive-site.xml</code>)</li>
  <li>Launch beeline shell: <code>beeline</code></li>
  <li>Connect beeline shell with Hive server-2: <code>!connect jdbc:hive2://localhost:10001/default;transportMode=http;httpPath=cliservice</code></li>
  </ol>
  
  <hr>
  
  <p>I've already tried the following things without any luck</p>
  
  <ol>
  <li>Making python 2.7.3 as default python version inside docker container (original default is python 2.6.6, python 2.7.3 is installed inside container but isn't default)</li>
  <li>Changing Hive server port to it's' default value: 10000</li>
  <li>Trying to connect with Hive server by running same python script inside the container (it still gives the same error)</li>
  </ol>