0

I am using xmlrpc to contact a local server. On the client side, Sometimes the following socket timeout error and happens and its not a consistent error. Why is it happening? What could be the reason for socket timeout?

<class 'socket.timeout'>: timed out
      args = ('timed out',)
      errno = None
      filename = None
      message = 'timed out'
      strerror = None 

Traceback on the server side is as follows

Exception happened during processing of request from ('127.0.0.1', 34855)
Traceback (most recent call last):
  File "/usr/lib/python2.4/SocketServer.py", line 222, in handle_request
    self.process_request(request, client_address)
  File "/usr/lib/python2.4/SocketServer.py", line 241, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.4/SocketServer.py", line 254, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.4/SocketServer.py", line 521, in __init__
    self.handle()
  File "/usr/lib/python2.4/BaseHTTPServer.py", line 314, in handle
    self.handle_one_request()
  File "/usr/lib/python2.4/BaseHTTPServer.py", line 308, in handle_one_request
    method()
  File "/usr/lib/python2.4/SimpleXMLRPCServer.py", line 441, in do_POST
    self.send_response(200)
  File "/usr/lib/python2.4/BaseHTTPServer.py", line 367, in send_response
    self.send_header('Server', self.version_string())
  File "/usr/lib/python2.4/BaseHTTPServer.py", line 373, in send_header
    self.wfile.write("%s: %s\r\n" % (keyword, value))
  File "/usr/lib/python2.4/socket.py", line 256, in write
    self.flush()
  File "/usr/lib/python2.4/socket.py", line 243, in flush
    self._sock.sendall(buffer)
error: (32, 'Broken pipe')

I killed the server and restarted it. Its working fine now. What could be the reason? My machine's RAM went full yesterday night by a process and came back to normal today morning. Will this error be because of some swapping of processes?

1
  • You can configure the socket timeout settings. You may have to do it on both ends or just on the client. For example if you call from PHP to python you may have to do it with PHP's socket timeout config variable Commented Aug 28, 2019 at 23:51

1 Answer 1

1

Looks like the client socket it timing out waiting for the server to respond. Is it possible that your server might take a lot time to respond some times? Also, if the server is causing the machine to go into swap, that would slow it down making a timeout possible.

If I remember right, socket timeout is not set in xmlrpc in python. Are you doing socket.setdefaulttimeout somewhere in your code?

If it is expected that your server will take time once in a while, then you could set a higher timeout value using above.

HTH

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks prashanth. There is a socket.setdefaulttimeout in the some of the old utils code.
I am not setting any timeout in my code. Yes my server will take time when its in swap state.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.