DMTF/python-redfish-library

TCP connection is closed after each response

davdr opened this issue · 2 comments

davdr commented

After each REST request (after receiving the response) the TCP connection to the server is closed. Is this intentional?

This happens here:

self.__destroy_connection()

Any "Connection: Keep-Alive" is not honored. Note that a bit earlier in the code it is honored:
if resp.getheader('Connection') == 'close':

Closing the connection every time is quite inefficient, as every subsequent request then requires setting up a new TCP connection, and in case of https, repeating the SSL/TLS negotiation.

On my test system, keeping the connection open instead of closing it, reduces execution time for https://github.com/DMTF/Redfish-Tacklebox/blob/master/scripts/rf_sensor_list from ~25 seconds to ~12 seconds.

I'm not sure why it was done like that in the first place; I agree it seems strange.

@jautor any idea about the history of that?

Everything I've found indicates it was done that way during early development of the standard, when implementations were "new". But those days are long past, and we see no reason to keep that inefficient behavior.