relay: add tests and implementation for socket session