stuff to prepare and initiate the middleware connection