Fixed connection handling for rpc