Fixes#1980.
An SSL handshake was missing and WsConnection should be build from
stream not socket because in case SSL connection stream already
completed SSL handshake.
Fixes#919.
Fixes bugs for new webserver:
- Unhandled exception when closing already closed websocket
- No pings for plain websocket connection
- Server drops websocket connection when client responds to pings but
doesn't send anything
Also changing API of ng connections. Now timeout is set by a separate
method instead of providing it for each call.