关于报错
happybase 是使用python连接hbase的一个第三方库,目前基于thrift1 。在使用过程中经常碰到报错

TTransportException(type=4, message='TSocket read 0 bytes')

即使使用thrift server首页上提供了连接Apache HBase Wiki on Thrift里的demo也一样报错。

测试代码
import happybase
def get_tables_name(host,port):
conn = happybase.Connection(host=host,port=port)
return conn.tables()
很简单,就是连接hbase,返回所有table名称。

报错可能原因
hbase 未开启thrift服务
Connection参数与thrift服务不匹配
Connection参数
看一下官网wiki上建立连接的例子

from thrift.transport.TSocket import TSocket
from thrift.transport.TTransport import TBufferedTransport
from thrift.protocol import TBinaryProtocol
from hbase import Hbase

transport = TBufferedTransport(TSocket(host, port))
transport.open()
protocol = TBinaryProtocol.TBinaryProtocol(transport)

client = Hbase.Client(protocol)

构建一个连接需要两个辅助类 TBufferedTransport,TBinaryProtocol。其中transport负责通讯协议,protocol负责序列化协议。

happybase connection
happybase官网上对于connection的介绍connection的介绍

总结有三个参数需要匹配

protocol: binary (the default) and compact
compat :0.90, 0.92, 0.94, or 0.96 (the default)
transport :buffered (the default) and framed
在我将上述测试代码改为

import happybase
def get_tables_name(host,port):
conn = happybase.Connection(host=host,port=port,protocol='compact',transport='framed')
return conn.tables()
就没问题了。
转自:https://blog.csdn.net/zhnxin_163/article/details/82879417

happybase(TSocket read 0 bytes)的更多相关文章

  1. pyhive -- thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

    Pyhive 远程连接hive出现问题: from pyhive import hive import pandas as pd #Create Hive connection conn = hive ...

  2. hue集成hbase出现TSocket read 0 bytes

    解决办法:修改hbase的配置文件 添加以下配置 https://stackoverflow.com/questions/20415493/api-error-tsocket-read-0-bytes ...

  3. HttpClient Received an unexpected EOF or 0 bytes from the transport stream

    请求https链接时报错,奇怪的是pc1正常,pc2异常 Unhandled Exception: System.AggregateException: One or more errors occu ...

  4. [Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.

    待解决 [Fiddler] ReadResponse() failed: The server did not return a complete response for this request. ...

  5. Mysql: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.

    2019-05-28 01:53:42.762 [message remind thread-24] ERROR druid.sql.Statement - {conn-10327, stmt-320 ...

  6. CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.

    今天,在用icinga服务器端测试客户端脚本时,报如下错误: [root@mysql-server1 etc]# /usr/local/icinga/libexec/check_nrpe -H 192 ...

  7. [Linux] Boot分区满了的处理方法 The volume "boot" has only 0 bytes disk space remaining

    1.查看系统目前正在用的内核 abby@abby:~$ uname -r ..--generic 2.查看/boot保存的所有内核 abby@abby:~$ ls -lah /boot total 3 ...

  8. Installation failed: Timeout was reached: Operation timed out after 10000 milliseconds with 0 out of 0 bytes received

    Trying this option worked for me. library(httr) with_config(use_proxy(...), install_github(...)) OR ...

  9. jeecms运行出现 Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.解决

    在/WEB-INF/config/application-context.xml中添加红色字体内容: <bean id="dataSource" class="co ...

随机推荐

  1. ijcai statistics

  2. Ext 向Ext.form.ComboBox()中添加列表的分类

    1.静态 [javascript] view plaincopy var staticComboBox = new Ext.form.ComboBox({   fieldLabel:'回访结果',   ...

  3. 1877. [SDOI2009]晨跑【费用流】

    Description Elaxia最近迷恋上了空手道,他为自己设定了一套健身计划,比如俯卧撑.仰卧起坐等 等,不过到目前为止,他 坚持下来的只有晨跑. 现在给出一张学校附近的地图,这张地图中包含N个 ...

  4. 【2016蓝桥杯省赛】试题C++ B组试题

    一.    煤球数目 作答:171700 #include <iostream> using namespace std; int main() { ,x=; ;i<=;i++){ ...

  5. POJ Football Game 【NIMK博弈 && Bash 博弈】

    Football Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 451   Accepted: 178 Descr ...

  6. C. Serval and Parenthesis Sequence 【括号匹配】 Codeforces Round #551 (Div. 2)

    冲鸭,去刷题:http://codeforces.com/contest/1153/problem/C C. Serval and Parenthesis Sequence time limit pe ...

  7. ZooKeeper分布式专题与Dubbo微服务入门

    第1章 分布式系统概念与ZooKeeper简介对分布式系统以及ZooKeeper进行简介,使得大家对其有大致的了解1-1 zookeeper简介1-2 什么是分布式系统1-3 分布式系统的瓶颈以及zk ...

  8. mysql root密码忘记重置及相关注意事项

    1.使用mysqld_safe --skip-grant-tables跳过授权,进入mysql操作界面或者在配置文件mysqld 添加skip-grant-tables也行,找回后需要删除..恢复原样 ...

  9. PAT乙级1007

    1007 素数对猜想 (20 分) 让我们定义d​n​​为:d​n​​=p​n+1​​−p​n​​,其中p​i​​是第i个素数.显然有d​1​​=1,且对于n>1有d​n​​是偶数.“素数对猜想 ...

  10. P1796 汤姆斯的天堂梦

    题目描述 汤姆斯生活在一个等级为0的星球上.那里的环境极其恶劣,每天12小时的工作和成堆的垃圾让人忍无可忍.他向往着等级为N的星球上天堂般的生活. 有一些航班将人从低等级的星球送上高一级的星球,有时需 ...