Why would socket.write hang indefinitely?

Viewed 129

What would make a write call to a TCPSocket hang indefinitely?

lotsOfBytes = # a really large number of bytes, like 1 or 2 MB of data

socket = TCPSocket.new # some config
socket.write(lotsOfBytes) # this line hangs

I am trying to debug an issue where a get_multi operation sent to memcached with a large number of keys hangs indefinitely, and it does so on a line that resembles that code snippet. I'm trying to better understand how the low-level sockets on which this library is built are expected to work.

2 Answers

What are the values of following attributes on your TCPSocket:

  • Keep-alive activated and what value is set?
  • Timeout set and what value is set?

If you will do a Wireshark dump, it's much better so see what happens before hanging connection.

  • tcpdump? are there any attempts to send anything?
  • netstat - for see output queue.
  • does it work on a small number of bytes in your environment?
Related