Fix bugs in json_socket