fixed undefined exception on relay.agent() without a connection