`

解决'RedisException' with message 'read error on connection'

阅读更多

PS:原创文章,如需转载,请注明出处,谢谢!     

本文地址:http://flyer0126.iteye.com/blog/1886635

 

       最近一直困扰的问题得到了解决。吐舌头

       项目中利用gearman实现异步处理,worker端涉及对mysql数据库及redis缓存的一系列操作,但是在实际的使用中发现很短时间后就会退出,开始查看log也没什么异常,通过程序端设置set_time_limit(0), try/catch 捕获异常、服务器端查看日志,通过strace 跟踪进程执行时的系统调用等等也没有什么改善,问题依旧,一时感觉很是无解啊。

       折腾至最后简化worker端功能,只简单实现redis的List 链表新增一项功能,结果没多长时间服务又停止了。这次查看日志有了新收获,通过查看php-fpm.log.error,发现如下一行提示:

[14-Jun-2013 10:32:30] PHP Fatal error:  Uncaught exception 'RedisException' with message 'read error on connection' in XXXX:35

 

       经过查找各方资料,发现是php.ini文件中的一个配置项导致:

default_socket_timeout = 60

       由于redis扩展也是基于php 的socket方式实现,因此该参数值同样会起作用。

 

       找到了问题就比较好解决了:

    1、直接修改php.ini,将其设置为我们想要的值(这个不推荐)

    2、在我们的脚本中通过以下方式设置,这样就比较灵活,不对其他脚本产生影响

ini_set('default_socket_timeout', -1);  //不超时

 

分享到:
评论

相关推荐

    Foundations for Analytics with Python O-Reilly-2016-Clinton W. Brownley

    The specific example is parsing a MySQL error log file, organizing the data into unique dates and error messages, and counting the number of times each error message appeared on each date. The ...

    微软内部资料-SQL性能优化3

    For example, a shared intent lock placed at the table level means that a transaction intends on placing shared (S) locks on pages or rows within that table. Setting an intent lock at the table level ...

    BURNINTEST--硬件检测工具

    disappeared with no error message. Release 5.3 build 1030 WIN32 release 25 September 2008 - Changes to investigate a BurnInTest crash problem on XP SP3. Release 5.3 build 1028 WIN32 release 11 ...

    S7A驱动720版本

    S7A驱动,7.20版本, Version history S7A OPC server and FIX driver for Siemens S7/S5 communication ... - Error in MIX Read function could cause blocking of data blocks...

    安装vagrant报错OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

    OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54 这个错误是因为网络太慢,下载virtualbox.box失败,可以换个网络再试一下。 如果网络实在太慢的话,可以试试下面的方法,我们可以手动下载virtualb

    http.client.IncompleteRead: IncompleteRead(0 bytes read)

    4. 最后,这个异常在 `requests.models` 模块的 `generate` 函数中被捕获,引发了 `requests.packages.urllib3.exceptions.ProtocolError`,并附带了关于连接被破坏的详细信息。 解决这个问题的方法通常包括以下几...

    UPnP_Programming_Guide

    - **4.1.20** `UPNP_E_SOCKET_CONNECT [-204]`: Indicates a connection error on a socket. - **4.1.21** `UPNP_E_OUTOF_SOCKET [-205]`: Signals that there are no more available sockets. - **4.1.22** `UPNP_E...

    计算机网络第六版答案

    22. Five generic tasks are error control, flow control, segmentation and reassembly, multiplexing, and connection setup. Yes, these tasks can be duplicated at different layers. For example, error ...

    php.ini-development

    error_reporting ; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED ; Development Value: E_ALL ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT ; html_errors ; Default Value: On ; ...

    Oracle sqldeveloper without jdk (win+linux)

    - Connection Delete Confirmation Window - message not read - Connections > right-click Export - not read - Connections > Tables > right-click - not reading clear filter - Connections > Database ...

    word自动转化为chm

    Create online documents from Word documents quickly with Word-2-Web. DocAuto products also contain other software that can be helpful to you: CommentAuto: Generate large amount of comments for you ...

    建伍378G写频软件

    reason, the "Check Connection Error" window open. Confirm that the transceiver is correctly connected to the computer via a KPG-22/46 cable, then select "[Retry]". Write To Radio Help This ...

    Go语言网络编程:net包的深度探索与实践

    log.Println("Error reading from connection:", err) break } fmt.Printf("Received from client: %s\n", buffer[:len]) // 发送响应数据 _, err = conn.Write(buffer[:len]) if err != nil { log.Println...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    - FIX Remaks panel focusing on main form (via PostMessage), since TreeInspector in FlexEditSE captures focus on self. - FIX Invalid arc size calculation when flex-control's size changes via DocRect ...

    QT项目之TCP通信的实现

    fill data with your message ... clientSocket.write(data); if (clientSocket.waitForBytesWritten()) { // successful write } QByteArray receivedData = clientSocket.readAll(); // process received...

    C#连接MYSQL示例代码

    Console.WriteLine("Error: " + ex.Message); } } } ``` 这个方法会打开连接,执行SQL语句(这里是非查询操作,如插入、更新或删除),然后关闭连接。如果在执行过程中发生异常,它将捕获并打印错误消息。 对于...

    idoc上传Step-by-step guide on File-to-IDoc using SAP PI 7.0

    Implement error handling mechanisms like Exception Classes and Message Types to manage errors during file retrieval or IDoc processing. D.2) Security Ensure proper security measures are in place for ...

    Sakemail

    just go tohttp://groups.yahoo.com/group/sakemail/History:0.9 - First released version0.9.1b -Fixed when a mail server reply on the connection with more than one line0.9.2b - I forget to return a value...

    端口查看工具

    o CurrPorts now displays a simple error message if it fails to close one or more TCP connections. * Version 2.01: o The 'Remote Address' and 'Local Address' columns are now sorted by the IP ...

    Node+Express+mysql实现CRUD

    if (err) return res.status(500).json({ error: err.message }); res.status(201).json({ message: 'User created', data: result }); }); }); ``` 读取(Read)操作可以通过GET请求实现,例如获取所有用户: ...

Global site tag (gtag.js) - Google Analytics