thrift error: [Errno 104] Connection reset by peer错误
thrift搭起来之后测试一切正常,但是过一段时间就会在日志里面报[Errno 104] Connection reset by peer错误, 但是如果这时候连thrift又一切正常,又能重新记录正确的日志.
日志如下:
[2017-07-20 15:21:40,818 INFO]: [thrift_api.<module>()]: [RPC SERVER]: starting the server...
[2017-07-20 15:21:58,457 INFO]: [thrift_api.infomation_extend_eb_data()]: [RPC SERVER]: Get ebusiness_data token:cbef95c048ea42e689c9b598552fff25 env: data_type:basic check_token: token_time:...[DONE]
[2017-07-20 15:43:03,172 ERROR]: [TServer.handle()]: [Errno 104] Connection reset by peer
Traceback (most recent call last):
File "/opt/services/venv/lib/python2.7/site-packages/thrift/server/TServer.py", line 127, in handle
self.processor.process(iprot, oprot)
File "../thrift_service_src/ThriftService.py", line 835, in process
(name, type, seqid) = iprot.readMessageBegin()
File "/opt/services/venv/lib/python2.7/site-packages/thrift/protocol/TBinaryProtocol.py", line 126, in readMessageBegin
sz = self.readI32()
File "/opt/services/venv/lib/python2.7/site-packages/thrift/protocol/TBinaryProtocol.py", line 206, in readI32
buff = self.trans.readAll(4)
File "/opt/services/venv/lib/python2.7/site-packages/thrift/transport/TTransport.py", line 58, in readAll
chunk = self.read(sz - have)
File "/opt/services/venv/lib/python2.7/site-packages/thrift/transport/TTransport.py", line 159, in read
self.__rbuf = StringIO(self.__trans.read(max(sz, self.__rbuf_size)))
File "/opt/services/venv/lib/python2.7/site-packages/thrift/transport/TSocket.py", line 105, in read
buff = self.handle.recv(sz)
error: [Errno 104] Connection reset by peer
[2017-07-20 15:45:29,168 INFO]: [thrift_api.infomation_extend_eb_data()]: [RPC SERVER]: Get ebusiness_data token:cbef95c048ea42e689c9b598552fff25 env: data_type:basic check_token: token_time:...[DONE]
启动部分代码如下:
if __name__ == "__main__":
# 设定端口
start_port_num = 8002
if len(sys.argv) == 2:
start_port_num = int(sys.argv[1])
# 配置服务
handler = ThriftInforExtendApi()
processor = ThriftService.Processor(handler)
# transport = TSocket.TServerSocket(port=start_port_num, host='localhost')
transport = TSocket.TServerSocket(port=start_port_num)
transport_factory = TTransport.TBufferedTransportFactory()
protocol_factory = TBinaryProtocol.TBinaryProtocolFactory()
# 配置服务器
server = TServer.TThreadedServer(processor, transport, transport_factory, protocol_factory)
# 启动服务
LOG.info("[RPC SERVER]: starting the server...")
server.serve()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个异常是由glibc里抛出的异常,是TCP协议定的。
异常是由于,接收方已经关闭了连接,而发送方不知道,这样发送方往接收方发数据的时候,接收方的TCP接到这个消息,说这个连接已经关闭了白了你一眼说重来(REST),叫你取号排队重新来。这时候就会有两种情况:
我重新握手,重新来,啥事没有,一切照旧。
我就不听你的,我再发一次包,然后对方就直接给你“Broken pipe”,吐一口痰给你。
所以,我猜,发送方为啥不知道接收方把socket close了是你这个问题的答案。