feature new param error-function in callbacks
fix not closed connections
fix if connection is closed do not try to sent the json headers/body