Fix RPC port autodetection bug